log-tracer
lightweight logger for node.js heavily inspired by log
and rotating-file-stream
Features
- default file output
- optional console output
- file rotation support
- log reader support
- cluster mode support
Usage
install
npm i log-tracer --save
import
//default options, 'debug' levelvar log = //levelStr option. var log = 'info' //statement level under 'info' will be ignored.log //record normallylog //would not be recorded //details with an object optionsvar log = levelStr: 'error' enableConsole: true
arguments
- levelStr {String}
debug
default
Details with an object
which have following attributes:
- logName {String} default
trace.log
- path {String} parent dir of the logfiles, recommend an absolue path. default
./trace
- size {String} rotation size for the file. default
20M
- maxFiles {Number} max number of files to be stored. default
10
- history {String} history file name for rotation. default
${logName}.txt
- enableConsole {Boolean} enable console output. default
false
- reader {Boolean} read log from file. default
false
Exapmle
//loggervar log = ;log;log;log; //readervar log = reader: true;log
log levels
- 0 EMERGENCY system is unusable
- 1 ALERT action must be taken immediately
- 2 CRITICAL the system is in critical condition
- 3 ERROR error condition
- 4 WARNING warning condition
- 5 NOTICE a normal but significant condition
- 6 INFO a purely informational message
- 7 DEBUG messages to debug an application