2.0.4 • Published 1 year ago

logophile v2.0.4

Weekly downloads
5
License
ISC
Repository
github
Last release
1 year ago

Logophile

A basic logging utility based on winston.

Usage

To use the logger, just require the package as follows

const logger = require('logophile');

Log Levels

The following log levels can be used by this logger:

  • debug
  • info
  • warn
  • error
  • trace

Each logger method can be called in the same way:

logger.info(message, logContext);

message -- string - The message describing the log

logContext -- object -- Optional Additional information you want to append to the log

NOTE: Error objects will be converted automatically to raw objects to expose potential appended properties.

Log Level Manipulation

To control what level logs are printed, users can set the level for the 'noisiest' logs they want to see:

Log Levels (From Highest Level to Lowest):

ERROR
WARN
INFO
TRACE
DEBUG

Additionally, you can use OFF for silencing logs during unit tests.

API Documentation

log

Used to log messages when you don't want to include any other information. This is analogous to a console.log() statement.

Usage:

logger.log('some message');

error

Logging an error message.

Usage:

logger.error('some message');

warn

Logging a warning message.

Usage:

logger.warn('some message');

info

Logging an info message.

Usage:

logger.info('some message');

debug

Logging a debug message.

Usage:

logger.debug('some message');

trace

Logging a trace message.

Usage:

logger.trace('some message');

setLogLevel

Changing the log level of the current object.

Usage:

logger.setLogLevel('info');

getLogLevel

Getting the current log level.

Usage:

logger.getLogLevel();

addGlobalLogContextKeys

Additional information you want to add to the global log context.

Usage:

logger.addGlobalLogContextKeys(keys);
2.0.3

1 year ago

2.0.2

1 year ago

2.0.4

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.3.0

1 year ago

1.2.0

2 years ago

1.1.5

2 years ago

1.1.4

3 years ago

1.1.3

3 years ago