mylogger
v1.1.5
Published
logging based on console
Downloads
32
Maintainers
Readme
mylogger
This module enables you to create logging based on console
Setting up
npm install mylogger
Usage
Input
// Patch console.x methods in order to add timestamp information
var logger = require("mylogger");
logger.setLevel('debug');// either of 'log', 'debug', 'info', 'notice', 'warn', 'error'
//logger.setLogPath('/var/log/testLog.txt'); //optional, if not set it will pipe to stdout
//use either setLogPath or useRotate
logger.useRotate({
dir: "/var/log",
fileName: "test.log",
rotateType: "minute", //minute/day/week/month/year
dateFormat: "yyyymmddhhMM",// a valid date format. For more see https://www.npmjs.com/package/dateformat Date formate will prepend on filename
useNewDir: true //if it is true there will be separate dir instead of appending on filename
});
logger.log("Hello", 'world');
logger.info("iiiiiiii", {txt: ['dummy']}, 'world');
logger.error("EEEEE", 'world')
logger.warn("ww", 'world')
logger.log("Hello World!", 'world');
Output
2015-11-26 15:24:02 [INFO] iiiiiiii { txt: [ 'dummy' ] } world
2015-11-26 15:24:02 [ERROR] EEEEE world
2015-11-26 15:24:02 [WARN] ww world