Have ideas to improve npm?Join in the discussion! »

    @ambassify/bunyan-logger

    3.1.5 • Public • Published

    bunyan-logger

    A drop-in replacement logger for console which logs to Loggly and the console. It includes support for CommonJS as well as ES Modules and has optimized builds for the browser. These are exposed through the various package.json entrypoints.

    Usage

    CommonJS

    const createLogger = require('@ambassify/bunyan-logger');
    const console = createLogger({ /* options */ });
    
    // or to get a preconfigured logger based on your environment
    const console = require('@ambassify/bunyan-logger/default');
    
    console.log('test'); // Logs to console and Loggly

    ES Modules

    import createLogger from '@ambassify/bunyan-logger';
    const console = createLogger({ /* options */ });
    
    // or to get a preconfigured logger based on your environment
    import console from '@ambassify/bunyan-logger/default.esm';
    
    console.log('test'); // Logs to console and Loggly

    Options

    Name Type Description
    name String Name for your logger. Required.
    notify Boolean Whether or not to output a log when a stream is enabled. Defaults to true. Can be overridden per stream.
    level String Minimal log level that gets emitted, lower levels are ignored. Can be overridden per stream.
    fields Object You can pass default fields for the logger here, these will be included on every log record.
    stdout Object Options for the console logger. Set to false to disable.
    serializers Object Bunyan serializers. The default serializers are always added.
    logUnhandled Boolean Whether or not to log unhandled errors, promise rejections, window.onerror events, ... Defaults to false.
    stdout.pretty boolean Whether or not to output pretty logs instead of raw JSON. Defaults to true.
    stdout.level String Minimal log level that gets emitted, lower levels are ignored.
    stdout.notify boolean Whether or not to output a log when this stream is enabled. Defaults to true.
    graylog Object Options for the GELF logger. Set to false to disable.
    graylog.endpoint string GELF endpoint of the graylog instance. Required.
    graylog.tags Array Tags to add to your graylog logs.
    graylog.level String Minimal log level that gets emitted, lower levels are ignored.
    graylog.notify boolean Whether or not to output a log when this stream is enabled. Defaults to true.

    Keywords

    Install

    npm i @ambassify/bunyan-logger

    DownloadsWeekly Downloads

    16

    Version

    3.1.5

    License

    MIT

    Unpacked Size

    110 kB

    Total Files

    50

    Last publish

    Collaborators

    • avatar