logsutil
v1.0.2
Published
Logging utility
Readme
logsutil
Logging utility for Node.js. Ships with multiple configurable sinks for routing log entries to different output targets.
Install
npm install logsutil
Usage
const logsutil = require('logsutil');
logsutil.dispatch({ severity: 'info', payload: 'hello world' });
Dispatch sends your entry straight through the default sink. No setup required.
Need more control? Create a pipeline, attach sinks, and pipe entries wherever you want.
const pipe = logsutil.create(); pipe.attach(logsutil.createStreamSink()); pipe.attach(logsutil.createFileSink({ directory: './logs' })); pipe.info('server started on port 3000');
Sinks
Four sinks included out of the box. Mix and match as needed.
StreamSink writes to stdout and stderr with optional formatting.
RotatingFileSink writes to disk with automatic rollover and optional brotli compression.
ExternalSink encodes and sends entries to an HTTP endpoint with retry logic. This is the one wired to the default dispatch call.
AggregateSink buffers entries and flushes them in batches on a configurable time window.
License
MIT
