1.0.3 • Published 7 years ago

nano-log v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

nano-logger

https://github.com/baontp/nano-logger.git

INSTALL

$  npm install nano-log --save

SUMMARY

This logger utility is inspired by github.com/quirkey/node-logger It can log onto file by date.

Instantiation:

create a logger with tag:

    let logger = require('nano-log').createLogger(TAG);

setup to log to file

    let log = require('nano-log');
    log.initLogFile('log_file');

Format:

yyyy-mm-dd HH:MM:ss TAG message

Usage:

A logger has 5 different levels of logging in a specific order:

'fatal', 'error', 'warn', 'info', 'debug'

Any of the logging methods take n arguments, which are each joined by ' ' (similar to console.log())

    logger.info('This is a info message');
    logger.warn(username, 'already logged in server');

set prefix in log

    logger.prefix = 'prefix 1';

Customization:

You can completely customize the look of the log by overriding the format() method on a logger.

logger.format = function(level, date, message) {
  return date.getTime().toString() + "; " + message;
};
logger.debug('message');
//=> 1276365362167;  message

COMMENTS/ISSUES:

Fork it, if you like.

LICENSE

MIT, see the source.

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago