codeql-action/node_modules/console-log-level
github-actions[bot] 0da815296a Update checked-in dependencies 2022-02-24 17:03:29 +00:00
..
LICENSE Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
README.md Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
index.js Initial commit (from f5274cbdce4ae7c9e4b937dcdf95ac70ae436d5f) 2020-04-28 17:23:37 +02:00
package.json Update checked-in dependencies 2022-02-24 17:03:29 +00:00

README.md

console-log-level

A dead simple logger. Will log to STDOUT or STDERR depending on the chosen log level. It uses console.info, console.warn and console.error and hence supports the same API.

Log levels supported: trace, debug, info, warn, error and fatal.

npm Build status js-standard-style

Installation

npm install console-log-level

Example usage

var log = require('console-log-level')({ level: 'info' })

log.trace('a') // will not do anything
log.debug('b') // will not do anything
log.info('c')  // will output 'c\n' on STDOUT
log.warn('d')  // will output 'd\n' on STDERR
log.error('e') // will output 'e\n' on STDERR
log.fatal('f') // will output 'f\n' on STDERR

Options

Configure the logger by passing an options object:

var log = require('console-log-level')({
  prefix: function (level) {
    return new Date().toISOString()
  },
  level: 'info'
})

level

A string to specify the log level. Defaults to info.

prefix

Specify this option if you want to set a prefix for all log messages. This must be a string or a function that returns a string.

Will get the level of the currently logged message as the first argument.

stderr

A boolean to log everything to stderr. Defauls to false.

License

MIT