This is a library that makes easier to write the formalized system log message in node.js application.
node-logger depends on winston
project
A log messages include timestamp
,log-level
,log-message
,file-location
,line-number
. If you write a log message in your node.js application, you can get log-files and log-message in your terminal
TODO
You should import node-formalized-logger
and get Logger instance. Generally, log collection is used throughout the application. That's why node-formalized-logger
library used a singletone design pattern
.
const log = require("node-formalized-logger").getInstance();
If you import library and get instance, you can write your log message depending on the message level
The ERROR level write a serious problem for the system.
log.error("db connection error");
2020-05-07T02:03:46.752Z (ERROR) [error]: db connection error at lib/Logger.js:14:50
The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
log.info("server is runnign on 80 port");
2020-05-07T02:03:46.754Z (INFO) [info]: server is runnign on 80 port at lib/Logger.js:14:47
The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
const email = "test@test.com";
log.debug(`user email is : ${email}`);
2020-05-07T02:03:46.755Z (DEBUG) [debug]: user email is : test@test.com at lib/Logger.js:14:56
The WARN level designates potentially harmful situations.
log.warn("invalid file format");
2020-05-07T02:03:46.755Z (INFO) [warn]: invalid file format at lib/Logger.js:14:53