Skip to content

qiwi/logwrap

Repository files navigation

logwrap

Bloody enterprise logger tools.

buildStatus Coverage Status dependencies Status devDependencies Status Maintainability js-standard-style

Motivation

Which logger to choose? Any. Because it doesn't matter at all. Just look at the problem from a different perspective. Logging is stateful data processing — pipeline of formatters, translators that ends in persistent storage. Really significant things:

  • Context detailing
  • Tracing (MDC)
  • Sensitive data masking

Install

yarn add @qiwi/logwrap
npm i @qiwi/logwrap

Usage

// logger.js 

import {Logwrap, masker as maskerFactory, mdc as mdcFactory} from '@qiwi/logwrap'
import winston from 'winston'
import DailyRotateFile  from 'winston-daily-rotate-file'

const { createLogger, transports: {Console}, config: {colorize}} = winston
winston.transports.DailyRotateFile = DailyRotateFile

const mdc =  mdcFactory()
const masker =  maskerFactory()
const logger = createLogger()
logger.configure({...})

const logwrap = new Logwrap({
  pipeline: [mdc, masker, logger],
  level: 'DEBUG'
})

export default logwrap