Print logs to a file using streams
npm install --save nutty-logfile
Initialize the module in your project:
var logfile = require('nutty-logfile');
Returns a new logfile object to print log messages to a file placed in path
. The optionally options
argument must be an object with the following keys:
encoding
: encoding. Default isutf8
.console
: print also messages in console. Default isfalse
.
var file = new logfile('/path/to/my/file.log');
Prints a log message with the specified level. See the supported levels list.
//Print a notice message to the file
file.notice('This is a notice message'); // Will print: [2017/01/30 11:02:33] [NOTICE] This is a notice message
Closes the stream file.
MIT LICENSE © Josemi Juanes.