Licence
MIT
Version
0.8.2
Deps
0
Size
5 kB
Vulns
0
Weekly
1.0K
@holz/json-backend
Prints structured logs to a writable stream in NDJSON form.
Usage
import { createJsonBackend } from '@holz/json-backend';
import { createLogger } from '@holz/core';
import * as fs from 'node:fs';
const logger = createLogger(
createJsonBackend({
stream: fs.createWriteStream('my-app.log', { flags: 'a' }),
}),
);Logs are output in NDJSON format. The output is optimized for log files, following the order of typical log statements. The output includes the log level, timestamp, message, and context, if provided.
The stream option specifies where the logs will be written to. You can use any writable stream, such as a file or process.stdout.