GitXplorerGitXplorer
w

console-log-level

public
111 stars
27 forks
8 issues

Commits

List of commits on branch master.
Verified
afb5409f1ad19e594f9ad2b7849619168cd184a5

1.4.1

wwatson committed 6 years ago
Verified
5fc1e4b749bdade64bc16d41eabc9efd32c14f69

chore: bump copyright year

wwatson committed 6 years ago
Verified
60e58d3eae3d81f49ec939e5e725dfaf2e5912a3

docs: improve README.md

wwatson committed 6 years ago
Verified
efc160234d4c0395306588628c4f01958fe23bde

test(ci): test on newer Node.js versions

wwatson committed 6 years ago
Verified
2a9f9d09c3b4e997ca2bd350e4fc1e091584471d

chore: reduce size of npm package

wwatson committed 6 years ago
Verified
c4e1adeab06817b139ec6dfd90d2cbfefac3504d

chore(package): bump all devDependencies

wwatson committed 6 years ago

README

The README file for this repository.

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