Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    raptor-loggingpublic

    raptor-logging

    Super simple logging system that works on the server and and in the browser.

    Example

    projects/logging-test/run.js:

    require('raptor-logging').configure({
        loggers: {
            'ROOT': 'WARN',
            'logging-test': 'DEBUG'
        }
    });
     
    // ...
     
    var logger = require('raptor-logging').logger(module);
    logger.debug('This is a debug message');

    Output:

    DEBUG logging-test/run: This is a debug message
    

    You can also pass multiple arguments, as well as non-String arguments to the logging methods.

    For example:

    var logger = require('raptor-logging').logger(module);
    logger.debug('This is a debug message', {foo: 'bar'});

    Output:

    DEBUG logging-test/run: This is a debug message { foo: 'bar' }
    

    Installation

    npm install raptor-logging --save

    API

    logger(module)

    Returns a new Logger instance whose name is based on the filename associated with the Node.js module object.

    Example:

    var logger = require('raptor-logging').logger(module);
    logger.debug('Hello World');

    logger(name)

    Returns a new Logger instance with the given name

    Example:

    var logger = require('raptor-logging').logger('foo');
    logger.debug('Hello World');

    Output:

    DEBUG foo: Hello World
    

    configure(options)

    Supported options:

    • loggers: A mapping of logger prefixes to log levels (see below)
    • appenders: An array of appender instances (see ConsoleAppender for an example appender implementation)

    Example:

    require('raptor-logging').configure({
        'ROOT': 'WARN',
        'foo': 'DEBUG',
        'foo/bar': 'WARN',
    });

    Logger

    Methods:

    • isTraceEnabled() : boolean
    • isDebugEnabled() : boolean
    • isInfoEnabled() : boolean
    • isWarnEnabled() : boolean
    • isErrorEnabled() : boolean
    • isFatalEnabled() : boolean
    • dump(arg1, arg2, ...)
    • trace(arg1, arg2, ...)
    • debug(arg1, arg2, ...)
    • info(arg1, arg2, ...)
    • warn(arg1, arg2, ...)
    • error(arg1, arg2, ...)
    • fatal(arg1, arg2, ...)

    Contributors

    Contribute

    Pull Requests welcome. Please submit Github issues for any feature enhancements, bugs or documentation problems.

    License

    Apache License v2.0

    Keywords

    none

    install

    npm i raptor-logging

    Downloadsweekly downloads

    5,557

    version

    1.1.3

    license

    Apache-2.0

    repository

    githubgithub

    last publish

    collaborators

    • avatar
    • avatar
    • avatar
    • avatar