node-formalized-logger

1.0.1 • Public • Published

node-logger

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

ERROR level

INFO level

WARN level

Terminal(console)

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

Package Sidebar

Install

npm i node-formalized-logger

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

8.1 kB

Total Files

4

Last publish

Collaborators

  • syunyun