Transporter
When a log is passed to a Transporter, it flows through three clear stages:
- 🔀 Normalization — Ensures a consistent, structured shape.
- 🎨 Formatting — Transforms the data into a readable format.
- 🖨 Output — Sends the final log to the destination console.
Note:
In Node.js, NodeConsoleTransporter lazily appends fields likepid
andhostname
.
This is done asynchronously to ensure that Logger.log() remains synchronous and returns immediately.
Built-in Transporters
Logry ships with platform-aware console transporters,
so your logs always show up in the right place—without any extra setup 🛠️
Platform | Transporter | Output target |
---|---|---|
Node.js | NodeConsoleTransporter | Terminal console |
Browser | BrowserConsoleTransporter | Browser developer console |
Edge | EdgeConsoleTransporter | Platform console (plain text) |
Each transporter activates only in its matching runtime, and does nothing otherwise.
Universal by Default
Importing from "logry" gives you a universal logger with both Node and browser transporters attached:
import { logry } from "logry"; // Includes both NodeConsoleTransporter and BrowserConsoleTransporter
logry.info("Hello from anywhere");
In Node.js, logs go to the terminal. In the browser, they appear in the browser console.
⚡️ No extra configuration required.
Platform-Specific Variants
To reduce bundle size or fine-tune behavior, you can import from a platform-specific entry point:
Import Path | Platform | Bound Transporter |
---|---|---|
"logry/node" | Node.js | NodeConsoleTransporter |
"logry/browser" | Browser | BrowserConsoleTransporter |
"logry/edge" | Edge | EdgeConsoleTransporter |
Each variant includes only the relevant transporter for its environment.
import { logry } from "logry/node"; // Logs only to terminal (no browser logic)
Edge Runtime Support
The "logry/edge" export is optimized for environments like Cloudflare Workers and other serverless platforms.
It uses EdgeConsoleTransporter, a minimal transporter that prints plain-text logs to the platform’s console.
⚠️ Always use logry/edge in Edge runtimes.
Other versions rely on Node.js APIs and may fail to run.
import { logry } from "logry/edge";
logry.info("Hello from the Edge");
Design Principle: Console Only
🔮 Unlike traditional loggers that mix console output with side-effects,
Logry keeps things clean and focused.
Transporters handle console output only; for other log deliveries, use Handlers.