raptor-logging

Module to support the optimized delivery of web application resources

Apache-2.0 22 个版本
安装
npm install raptor-logging
yarn add raptor-logging
pnpm add raptor-logging
bun add raptor-logging
README

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

版本列表
1.1.3 2017-08-03
1.1.2 2016-05-31
1.1.1 2016-04-27
1.1.0 2016-04-08
1.0.8 2016-01-27
1.0.7 2015-11-17
1.0.6 2015-05-29
1.0.5 2014-12-17
1.0.4 2014-11-07
1.0.3 2014-10-16
1.0.2 2014-10-08
1.0.1-beta 2014-09-04
1.0.1 2014-09-22
1.0.0-beta 2014-09-04
0.2.6-beta 2014-06-18
0.2.5-beta 2014-06-08
0.2.4-beta 2014-06-05
0.2.3-beta 2014-05-27
0.2.2-beta 2014-04-15
0.2.1-beta 2014-03-13
0.2.0-beta 2014-02-26
0.1.0-SNAPSHOT 2014-01-13