Skip to content

nuttyjs/nutty-logfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nutty-logfile

npm npm npm

Print logs to a file using streams

Installation

npm install --save nutty-logfile

API

Initialize the module in your project:

var logfile = require('nutty-logfile');

var file = new logfile(path, [ options])

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 is utf8.
  • console: print also messages in console. Default is false.
var file = new logfile('/path/to/my/file.log');

file.(message)

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

file.end()

Closes the stream file.

Related

  • nutty A small and minimal CLI framework.
  • nutty-log Logger for cli apps and nutty middlewares

License

MIT LICENSE © Josemi Juanes.