Node Packaged Masterfully

    debugnyan
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    debugnyan

    A logging library that combines the simplicity and convenience of debug with the power of bunyan.

    Status

    npm version build status

    Installation

    Install the package via yarn:

    ❯ yarn add debugnyan

    or via npm:

    ❯ npm install debugnyan --save

    Usage

    Create a logger by giving it a namespace and then call bunyan's log methods on the returned instance.

    By default, similarly to debug's behaviour, 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.

    Consider a logger named foo:bar:biz:

    • this creates a bunyan logger with name foo
    • and a bunyan (simple) child logger with property component equal to bar.
    const logger1 = require('debugnyan')('foo');
    const logger2 = require('debugnyan')('foo:bar');
    
    logger1.debug('net');
    logger2.debug('qux');

    Example output with DEBUG=foo:

    DEBUG=foo node example.js
    
    {"name":"foo","hostname":"ruimarinho","pid":1,"level":20,"msg":"net","time":"2016-10-04T18:54:14.530Z","v":0}
    {"name":"foo","hostname":"ruimarinho","pid":1,"component":"bar","level":20,"msg":"qux","time":"2016-10-04T18:54:14.531Z","v":0}

    Example output with DEBUG=foo:bar:

    DEBUG=foo:bar node example.js
    
    {"name":"foo","hostname":"ruimarinho","pid":2,"component":"bar","level":20,"msg":"qux","time":"2016-10-04T18:55:08.217Z","v":0}

    The prefix and suffix for each component is also customizable:

    const logger = require('debugnyan')('foo', {}, { suffix: 'module' });

    When creating a child logger you may also override the default simple behavior:

    const logger = require('debugnyan')('foo', {}, { suffix: 'module', simple: false });

    Tests

    ❯ yarn test
    

    Release

    ❯ yarn release ["major" | "minor" | "patch" | <custom version number>] # default: patch

    License

    MIT

    Install

    npm i debugnyan

    DownloadsWeekly Downloads

    30,723

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    8.83 kB

    Total Files

    6

    Last publish

    Collaborators

    • satazor
    • americas
    • kurayama
    • pedrobranco
    • nunofgs
    • fixe
    • franciscocardoso
    • cristiano.oliveira
    • ruimarinho
    • ricardolopes
    • joaofonseca