0.0.1 • Published 5 years ago

@darthhahn/tolog v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

tolog

Logs messages to files.

Usage

To start logging, run the start method. This will initialize options and open the file stream.

var tolog require('../index');

tolog.start({
    path: './to.log',
    logToConsole: true
});

There are multiple methods available for logging. Each method prepends the date and time to each appended line in the format 2019-01-11T00:00:00-07:00.

// appends `$date info foo` to log file
tolog.info('foo');

// appends `$date error bar` to log file
tolog.error('bar');

Logging with custom context is also supported.

// appends `$date foo bar` to log file
tolog.log('foo', 'bar');

To stop logging to file, execute the end method.

tolog.end();

Options

OptionDefault
logToConsolefalseIf true, messages will log to file and console.
path./to.logFile path of log file.

Testing

tolog uses the jest framework. To execute all tests, run npm test.