slf-debug
v0.4.0
Published
Surikat Log Facade, debug-js/debug driver
Maintainers
Readme
slf-debug
SLF driver that sends logs to debug.
Install
npm install slf slf-debug debugQuick start
import debug from 'debug';
import { LoggerFactory } from 'slf';
import slfDebug from 'slf-debug';
debug.enable('api:*');
LoggerFactory.setFactory(slfDebug);
const log = LoggerFactory.getLogger('api:users');
log.info('User loaded: %s', '123');Enable logs with DEBUG
The driver uses the SLF logger name as its debug namespace. Set DEBUG before starting your application to select which names produce output:
DEBUG=api:* npm startThis enables logs from api:users and other api:* loggers. Use DEBUG=* to enable all namespaces, or a comma-separated list such as DEBUG=api:*,worker:billing:* to enable several. Without a matching DEBUG namespace (or a call to debug.enable() as shown above), the debug driver produces no output.
DEBUG controls which logger names are enabled; SLF_LOG_LEVEL independently sets the minimum log level (for example, SLF_LOG_LEVEL=info DEBUG=api:* npm start).
Behavior
- Reuses one
debuglogger per SLF logger name. - Prepends each message with ISO timestamp and uppercase level.
- If first param is a string, it is combined with the prefix.
- If params contain
Error, stack/message is used for better readability.
Example output shape:
2026-04-27T09:30:00.000Z INFO User loaded: 123Recommended namespaces
Use structured logger names so debug.enable() filters are useful:
api:*worker:billing:*http:request
