GithubHelp home page GithubHelp logo

node-service-logger's Introduction

node-service-logger

A helper to instantiate winston loggers for my javascript web-services

Usage

Initialise the logger in the service main routine:

import {initLogger, getLogger} from "service-logger";

initLogger({level: "info"});

const logger = getLogger("main");

log.debug("debug me");
log.info("inform me");
log.crit("this is critical");

Use in a service component such as an included file:

import {getLogger} from "service-logger";

const logger = getLogger("main");

log.debug("debug me");
log.info("inform me");
log.crit("this is critical");

Rationale

I need a standardised way for logging in my micro services, so I can pull them into a system like prometheus. I want a standardised machine readable logging format with a standardised levels across my services.

I use winston logger for its flexibitly.

Requirements

  • All logs use the JSONL format.
  • All logs have timestamps.
  • Internal components of a service are identifyable.
  • Activate logging levels for individual components, centrally

Logging levels

I use 9 levels of logging, which follow the principles of RFC5424 Table 2. I added two additional levels: performance and data. performance records performance metrices, which are always reported. data messages are reserved for super low level debugging, when data introspection is needed. This level should be used when exposing privacy related data, security related data, or very large data objects.

  • performance: performance metrices
  • emergency: unrecoverable errors
  • alert: major but resolvable problems (e.g., connection errors)
  • critical: critical errors (e.g., for security relevant information)
  • error: service errors (e.g., when access is denied)
  • warning: component errors (e.g., when a component is skippeds)
  • notice: noteworthy (for conformance purposes)
  • info: runtime information
  • debug: detailed logging
  • data: for super detailed logging of data when bug hunting, which may include confidential information

node-service-logger's People

Contributors

dependabot[bot] avatar phish108 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.