logging-timely
v1.1.0
Published
an npm to log every error and save it to file
Downloads
7
Readme
#Installation Using npm :
npm install logging-timely
#How to Use ##log of one file let logging = require('logging-timely'); //object creation let log = new logging(); //set filename and directory for log log.fileName = 'error'; log.directory = './log/'; //set time of logging log.logOnce(); //initial logging log.createLog(); //write log log.write('i am log'); // time of log inserted will also be written ##log of per minute log.filename = 'error'; log.logMinutely(); log.createLog(); setInterval() log.Minutely('i am log');
#Attribute ##fileName you can create file name, but the filename will get prefix of time you use as log ###set log.fileName = 'error'; ###get log.fileName if you use minutely as logging then the filename would be DD_MM_YYYY-hh_mm_filename.log ##directory ###set log.directory = './logHour/'; don't forget to use ./ before and / after directory name ###get log.directory
#Method used ##timely ###logOnce() set time of log to only one time logging file ###logMinutely() set time of log to create one logging file per minute ###logDaily() set time of log to create one logging file daily ###logHourly
Open and Ending Log
###createLog() create file to stream ###endLog() closing file stream
##Write Messages ###write() write message to file (to only a file) ###Monthly write message to file Monthly(change file log monthly) ###Hourly() write message to file hourly (change file log Hourly) ###Minutely() write message to file minutely (change file log minutely) ###Daily() write message to file daily (change file log daily)
#Example program let logging = require('./npm-logging'); let path = require('path'); let log = new logging(); log.directory = './logMinute/'; log.fileName = path.basename(__filename); log.logMinutely(); let logHourly = new logging(); logHourly.directory = './logHour/'; logHourly.logHourly(); let logDaily = new logging(); logDaily.directory = './logDay/'; logDaily.logDaily(); let logMonthly = new logging(); logMonthly.directory = './logMonth/' logMonthly.logMonthly();
//open stream log
log.createLog();
logHourly.createLog();
logDaily.createLog();
logMonthly.createLog();
//function
setInterval(writeMessages,10000);
function writeMessages(){
log.Minutely('i am in minutely log');
logDaily.Daily('i am in daily log');
logHourly.Hourly('i am in hourly log');
logMonthly.Monthly('i am in monthly log');
}