1.0.1 • Published 4 years ago

node-formalized-logger v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

node-logger

npm.io

Introduce

This is a library that makes easier to write the formalized system log message in node.js application.

Dependency

node-logger depends on winston project

Formalized Log Format

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

Log file

DEBUG level

npm.io

ERROR level

npm.io

INFO level

npm.io

WARN level

npm.io

Terminal(console)

npm.io

Installation

NPM

TODO

Usage

1. require libs

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();

2. write log

If you import library and get instance, you can write your log message depending on the message level

ERROR 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

INFO level

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

DEBUG level

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

WARN level

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