npm i node_smart_logger
import SmartLogger from 'node_smart_logger';
const _logger = new SmartLogger();
By default logger will create a logs folder in the root of your project, but you can also indicate the path and name of the logs folder when you initialize it:
const config = {
logs_folder_path: "./someDir/anotherDir",
logs_folder_name: "anotherLogsFolderName"
}
const _logger = new SmartLogger(config);
// Info log
_logger.setInfo("message");
//[2022-5-28 9:21:6] - [info] - message | [data]: {}
// Error log
_logger.setError("message");
//[2022-5-28 9:21:6] - [error] - message | [data]: {}
// Alert log
_logger.setAlert("message");
//[2022-5-28 9:21:6] - [alert] - message | [data]: {}
// Debug log
_logger.setDebug("message");
//[2022-5-28 9:21:6] - [debug] - message | [data]: {}
// Critical log
_logger.setCritical("message");
//[2022-5-28 9:21:6] - [critical] - message | [data]: {}
// Warning log
_logger.setWarning("message");
//[2022-5-28 9:21:6] - [warning] - message | [data]: {}
// Success log
_logger.setSuccess("message");
//[2022-5-28 9:21:6] - [success] - message | [data]: {}
const dataToLog = {
error: false,
message: 'some message'
}
_logger.setCritical("log message", dataToLog);
//[2022-5-28 9:21:6] - [critical] - log message | [data]: {"error":false,"message":"some message"}
_logger.setSteep({message: 'some message',number: 5});
//[ steep 5 ] :::: some message
_logger.setCantity({message: 'Total Records', total: 100});
//Total Records [100]
_logger.setInterval({message: 'Record Processed', actual: 5, total: 100});
//Record Processed [5] of [100]
_logger.setTitle({message: "This is a error tittle", level: "error"});
- info
- warning
- error
- alert
- critical
- success
- degub
_logger.logExpressRequest(req:Request, res:Response, next:NextFunction);
//[2022-5-28 22:5:49] - [info]-[express] | [endpoint] [GET] /process-file/icbc_test | [headers] {"content-type":"application/json","host":"localhost:3000"} | [params] {"param1":"value1"} | [body] {}