raptor-logging

1.1.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i raptor-logging

Weekly Downloads

1,076

Version

1.1.3

License

Apache-2.0

Last publish

Collaborators

  • dylanpiercey
  • austinkelleher
  • pnidem
  • philidem