Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-meta-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-meta-wrapper

Wraps Winston logger to always add a set of metadata

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

winston-meta-wrapper

Wraps winston logger instance to always add a set of metadata

This wrapper around winston loggers allows you to log a static or dynamic set of metadata with each log statement being executed without explicitely adding it as meta argument.

It also fixes the JSON string interpolation issue in winston

Installation

npm install winston-meta-wrapper

Usage

Wrapping Winston Logger to add static metadata

var winston = require('winston')
var winstonWrapper = require('winston-meta-wrapper')

var logger = new winston.Logger({
  transports: [
    new winston.transports.Console()
  ]
})

logger = winstonWrapper(logger)

logger.addMeta({
  test: 'Test Meta'
})

logger.info('test message')

Wrapping Winston Logger to add dynamic metadata

var winston = require('winston')
var winstonWrapper = require('winston-meta-wrapper')

var logger = new winston.Logger({
  transports: [
    new winston.transports.Console()
  ]
})

logger = winstonWrapper(logger)

logger.getMeta = function () {
  return {
    module: Math.random()
  }
}

logger.info('test message')
logger.info('test message')

Chaining wrapped Winston Loggers

var winston = require('winston')
var winstonWrapper = require('winston-meta-wrapper')

var logger = new winston.Logger({
  transports: [
    new winston.transports.Console()
  ]
})

logger = winstonWrapper(logger)

logger.addMeta({
  test: 'Test Meta'
})

logger = winstonWrapper(logger)

logger.addMeta({
  test2: 'Test 2 Meta'
})

logger.info('test message')

Keywords

FAQs

Package last updated on 11 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc