A simple async logger with typed log levels, timestamped output, and a clean port-and-adapter architecture for interchangeable implementations. Built with TypeScript and 0 dependencies.
- Structured logging via
trace(),info(),warn(), anderr() - Configurable log level on instantiation:
"trace" | "info" | "warn" | "err" - Messages below the configured level are automatically filtered out
- Zero dependencies — portable, embeddable, and safe for small runtimes
- Implementation-agnostic design: adapters (
CliLogger,BrowserLogger,NullLogger, File, Remote, …) - Implementation can be swapped without code changes
To produce this log:
2025-02-14T22:24:03.447Z [INFO] prod-node2(5193): main.ts: server started
use this code:
import { CliLogger } from "@papack/log";
const log = new CliLogger({ loglevel: "info" }); // minimum level is "info"
log.info("main.ts", "server started");import { BrowserLogger } from "@papack/log";
const log = new BrowserLogger({ loglevel: "info" });
log.warn("app.ts", "API latency high");The browser prints the same timestamped format, but using CSS instead of ANSI Color and do not include proccess id or hostname.
If you want to disable logging without changing your application logic:
import { NullLogger } from "@papack/log";
const log = new NullLogger();All log calls are discarded with near-zero overhead.
- Write logs to the filesystem
- Automatic logfile rotation
- Each log entry receives a UUID and is exposed via HTTP
- JSON data structure instead of human-readable format ([{uuid,time,host,pid,msg}])
- Dedicated listening port
- API-key authentication
- A included
RemoteLogCollectorfunction can be used on a remote host- acknowledges collected entries by returning the UUID
- A local Logger (FileLogger, CliLogger, NullLogger etc) can injectet on remote host to show logs from multi remotes
- Exposes metrics: number of trace, info, warn, and err entries
- Same as Remote Log, but compatible with Node.js Cluster mode
- Full multi-adapter compatibility