@rotorsoft/act-pino
Pino logger adapter for the @rotorsoft/act event sourcing framework.
Replaces Act's built-in ConsoleLogger with pino — structured JSON logging, log levels, transports, redaction, and pretty-printing in development.
Install
pnpm add @rotorsoft/act-pino
Quick Start
import { log } from "@rotorsoft/act";
import { PinoLogger } from "@rotorsoft/act-pino";
log(new PinoLogger());
Configuration
PinoLogger accepts an options object:
level | string | config().logLevel | Log level (trace, debug, info, warn, error, fatal) |
pretty | boolean | true in non-production | Enable pino-pretty for human-readable output |
options | pino.LoggerOptions | {} | Pass-through to pino (transports, serializers, redaction, etc.) |
Examples
log(new PinoLogger({ level: "debug" }));
log(new PinoLogger({ pretty: false }));
log(new PinoLogger({
options: {
redact: ["password", "secret", "token"],
serializers: {
req: (req) => ({ method: req.method, url: req.url }),
},
},
}));
Logger Interface
PinoLogger implements the Act framework's Logger interface:
interface Logger {
level: string;
trace(obj: unknown, msg?: string): void;
debug(obj: unknown, msg?: string): void;
info(obj: unknown, msg?: string): void;
warn(obj: unknown, msg?: string): void;
error(obj: unknown, msg?: string): void;
fatal(obj: unknown, msg?: string): void;
child(bindings: Record<string, unknown>): Logger;
dispose(): Promise<void>;
}
String and object messages
const logger = new PinoLogger();
logger.info("Server started");
logger.info({ port: 4000 }, "Server started");
logger.info({ event: "startup", port: 4000 });
Child loggers
Create scoped loggers with inherited bindings:
const parent = new PinoLogger();
const child = parent.child({ module: "payments" });
child.info("Processing payment");
Cleanup
await logger.dispose();
Environment Integration
PinoLogger reads defaults from Act's config():
logLevel — controlled by LOG_LEVEL env var (default: "info")
logSingleLine — controlled by LOG_SINGLE_LINE env var (affects pino-pretty formatting)
env — when "production", pretty-printing is disabled by default (structured JSON output)
License
MIT