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

abstract-winston-json

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-winston-json

A Simple JSON Logging Tool that is built on top of Winston

  • 1.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Abstract Winston JSON Logging Tool

A Simple JSON Logging Tool that is built on top of Winston

Installation

Yarn:

yarn add abstract-winston-json

NPM:

npm install abstract-winston-json

Output

{
  "type": "log.type",
  "message": {
    "data": {
      "more": "data",
    },  
  },
  "metadata": {
    "userId": "123ABC",
  },
}

API

Logger

Parameters
ParamTypeDescriptionDefault Value
metadataObjectMetadata Object{}
debugModeBooleanDebug Modefalse
Example
const Logger = require('abstract-winston-json');

// Metadata to include in every log.
const metadata = {
  userId: 'ABC123',
};

// Debug Mode Off
const logger = new Logger({ metadata });

// Debug Mode On
const logger = new Logger({
  metadata,
  debugMode: true,
});

addMetadata(key, value)

Add Metadata to include in every log.

Parameters
ParamTypeDescriptionDefault Value
keyStringMetadata Key
valueAnyMetadata Value
Example
logger.addMetadata('key', 'value');

removeMetadata(key)

Remove specific Metadata from logs from now on.

Parameters
ParamTypeDescriptionDefault Value
keyStringMetadata Key{}
Example
logger.removeMetadata('key');

log(type, message)

Log via the info level.

Parameters
ParamTypeDescriptionDefault Value
typeStringLog Type Key
messageAnyLog Message
Example
logger.log('log.type', {
  requestInfo: 'example',
  data: {},
});

warn(type, message)

Log via the warn level.

Parameters
ParamTypeDescriptionDefault Value
typeStringLog Type Key
messageAnyLog Message
Example
logger.warn('warn.type', {
  requestInfo: 'example',
  data: {},
});

error(type, message) || err(type, message)

Log via the error level.

Parameters
ParamTypeDescriptionDefault Value
typeStringLog Type Key
messageAnyLog Message
Example
logger.error('error.type', {
  requestInfo: 'example',
  data: {},
});
logger.err('error.type', {
  requestInfo: 'example',
  data: {},
});

debug(type, message)

Will only log when debug mode is set to true. Logs via the info level.

Parameters
ParamTypeDescriptionDefault Value
typeStringLog Type Key
messageAnyLog Message
Example
logger.debug('error.type', {
  requestInfo: 'example',
  data: {},
});

getLogger()

Gets the underlying Winston Logging Instance

Example

const winston = logger.getLogger();

FAQs

Package last updated on 27 Feb 2019

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