Structured observability toolkit with pluggable transports.
Lightweight logging abstraction with a Logger interface and two built-in transports:
- Console — structured JSON output via
console[level] - File — file-based logging via pino (optional peer dependency)
pnpm add @arckit/observabilityFor the file logger, also install pino:
pnpm add pinoimport { consoleLogger } from '@arckit/observability';
const logger = consoleLogger();
logger.log({ level: 'info', event: 'user.created', payload: { userId: '123' } });
// console.info('{"event":"user.created","userId":"123"}')import { fileLogger } from '@arckit/observability';
const logger = fileLogger({ path: './logs/app.log', console: true });
logger.log({ level: 'error', event: 'payment.failed', payload: { orderId: '456' } });type Logger = {
log: (entry: LogEntry) => void;
};type LogEntry = {
level: LogLevel;
event: string;
payload?: Record<string, unknown>;
};type LogLevel = 'debug' | 'info' | 'warn' | 'error';Creates a logger that outputs structured JSON to the console using console[level].
| Parameter | Type | Description |
|---|---|---|
config.path |
string |
File path for log output |
config.console |
boolean? |
Also output to console with pino-pretty |
Creates a logger that writes structured logs to a file via pino. Automatically creates the directory if it doesn't exist.
See CONTRIBUTING.md for details.
MIT © Marc Gavanier