1.0.3 • Published 4 years ago

filoggy v1.0.3

Weekly downloads
15
License
-
Repository
-
Last release
4 years ago

Filoggy

https://github.com/chindit/filoggy

SUMMARY

A simple logging library for Node.JS

USAGE

Filoggy has 5 different levels of logging in a specific order:

['fatal', 'error', 'warning', 'info', 'debug']

Each of these log levels has its own method on the logging instance.

For example:

logger.warning('Hello world!')
logger.error('Damn!')
logger.fatal('That\'s an error!')
logger.info('Oh, by the way, an info')
logger.debug('Dear developer, I\'m a debug log')

By default, a logger writes to STDOUT, but given a writable file path, it will log directly to a file.

If not file is provided or if file is not writable, NOTICE will be triggered in the console.

You can also provide some context as a second param. This context can be whatever you want: string, numbers or objects. Scalar variables will be converted to string and objects will be stringified as JSON.

Example:

logger.error('Oh, no!  It failed!', {my: 'ym', object: 'tcejbo'})

Instantiation:

const logger = require('filoggy').createLogger(); // logs to STDOUT
const logger = require('filoggy').createLogger('development.log'); // logs to a file

Ouput:

For example, this log:

logger.error('Hello!')

Will produce following output:

Tue May 01 2018 19:29:20 GMT+0200 (CEST) [ERROR] Hello! []

LICENSE

AGPL v3

1.0.3

4 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.2

6 years ago