@stack-hq/logger
v1.0.0
Published
Structured logging with levels, JSON/pretty output, child loggers, redaction, and timers.
Maintainers
Readme
@stack-hq/logger
Structured logging with levels, JSON or pretty output, child loggers, automatic redaction of sensitive fields, and a time() helper.
Install
npm install @stack-hq/loggerUsage
import { Logger } from "@stack-hq/logger";
const log = new Logger({ name: "api", level: "info", format: "json" });
log.info("server started", { port: 3000 });
const requestLog = log.child({ requestId: req.id });
requestLog.warn("slow query", { durationMs: 820 });
await log.time("db.query", () => db.users.findMany());Sensitive fields (password, token, secret, authorization by default) are automatically redacted from logged objects — configure via redactKeys.
License
MIT
