loggee
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Loggee

Tiny JavaScript logger with namespaces. Work in both Node.js and browser.

Installation

npm install loggee --save

Usage

Require and set namespace in one line:

const logger = require('loggee').create('My module');
 
logger.log('Hello world!'); // => [My module] Hello World!
logger.info('Hello world!'); // => [My module] Hello World!
logger.warn('Hello world!'); // => [My module] Hello World!
logger.error('Hello world!'); // => [My module] Hello World!
logger.debug('Hello world!'); // => [My module] Hello World!

Mute

You can mute logger globally:

const loggee = require('loggee');
 
loggee.setLogLevel('error'); // show only errors
loggee.setLogLevel('none');  // mute

API

create([prefix])

  • prefix {String} prefix to be prepended to all messages of that logger.
  • returns: {Logger}

Creates logger with specified prefix.

setLogLevel(level)

  • level {String} log level for all loggers. Possible values are: debug|log|warn|error|none.

Sets new log level for all loggers.

setOnErrorHandler(handler)

  • handler {Function}

Sets handler to be called on every error.

mute(value)

  • value {Boolean}

Mute/unmute all loggers.

logger.debug(...)

Outputs debug message.

logger.log(...)

Outputs log message.

logger.info(...)

Outputs info message.

logger.warn(...)

Outputs warning.

logger.error(...)

Outputs error.

License

MIT @ Vitaliy Potapov

Readme

Keywords

Package Sidebar

Install

npm i loggee

Weekly Downloads

10

Version

0.2.0

License

MIT

Unpacked Size

7.98 kB

Total Files

7

Last publish

Collaborators

  • vitalets