A logging library that combines the simplicity and convenience of debug with the power of pino
npm install @uphold/debino

A logging library that combines the simplicity and convenience of debug with the power of pino.
``bash`
npm install @uphold/debino
By default, similarly to debug's behavior, loggers do not output any content. Each logger output can be selectively activated by using the DEBUG environment variable. Pattern matching is based on the logger's name and it can optionally contain colons (:) to create (sub)-components properties on the logger instance.
A logger named foo:bar:biz creates a pino child logger with name equal to foo, property component equal to bar and subcomponent equal to biz.
Considering the following example:
`js
// example.js
import { debino } from '@uphold/debino';
const child1 = debino('foo');
const child2 = debino('foo:bar');
child1.debug('net');
child2.debug('qux');
`
Example output with DEBUG=foo*:
`bash
DEBUG=foo* node example.js
{"level":20,"time":1734717092221,"pid":99831,"hostname":"Andr-Cruz-0688L","name":"foo","msg":"net"}
{"level":20,"time":1734717092221,"pid":99831,"hostname":"Andr-Cruz-0688L","name":"foo","component":"bar","msg":"qux"}
`
Example output with DEBUG=foo:bar:
`bash
DEBUG=foo:bar node example.js
{"level":20,"time":1734717270874,"pid":1035,"hostname":"Andr-Cruz-0688L","name":"foo","component":"bar","msg":"qux"}
`
The prefix and suffix for each component is also customizable:
`js`
const child = debino('foo', { suffix: 'module' });
When creating a child logger, you may also pass any options accepted by pino.child() method:
`js`
const child = debino('foo', { redact: ['foo']});
The level pino option is respected if the logger output is active.
`js`
const logger = debino('root')('foo', { level: 'info' });
You may also set the log level via the LOG_LEVEL environment variable. However, the level option will always take precedence over it.level
If both and LOG_LEVEL are not set, it will use the value from
the root logger (See the Root Logger section below for more information).
Every call to debino creates a child logger based on a root logger. The default root logger is an instance returned by pino({ level: 'debug' }). You may set your own root logger by calling setRootLogger():
`js
import { debino, pino, setRootLogger } from '@uphold/debino';
// Call this as soon as possible in your application.
setRootLogger(pino({ redact: ['foo'] }));
const logger = debino('foo');
`
Install dependencies:
`bash`
npm i
Run tests:
`bash``
npm run test
The release process is automated via the release GitHub workflow. Run it by clicking the "Run workflow" button.