🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

winstonjs-fingers-crossed-transport

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winstonjs-fingers-crossed-transport

Fingers crossed transport for WinstonJS logger

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Fingers Crossed Winston Transport

This library implements a transport for Winston loggers that works as a regular transport while the service is working normally but automatically switches to a verbose mode when an error occurs, in an attempt to provide more context to help diagnose the issue. In this verbose mode, the transport will print debugging messages that would normally be discarded.

Usage

import { FingersCrossedTransport } from '@kristijorgji/winstojns-transport-fingers-crossed'
import { createLogger, transports } from 'winston';

const transport = new FingersCrossedTransport(new transports.Console(), {
  // Prints all messages with level >= info and switches to verbose mode when a
  // message with level >= warn arrives
  standardLevel: 'info',
  activationLevel: 'warn',
});

const logger = createLogger({ transports: [transport] });

Configuration options

OptionDescription
standardLevelNormal logging threshold, i.e., messages with a lower level won't be printed and messages with level greater than or equal will be printed immediately.
Typically info or warn.
activationLevelThreshold level at the transport will switch to verbose mode and print detailed logging messages that were not displayed before.
Typically warn or error
maxItemsInBufferMaximum number of messages to keep in buffer in order to avoid memory leak if activation threshold is never reached.
Defaults to undefined (no limit)
resetOnActivationIf set to true then when activationLevel is reached all logs are flushed(logged) then logger is reset. Will not print out anything until next activation level is reached
Defaults to true

reset

When a message with logging level >= activationLevel arrives, the transport switches to verbose mode and starts logging all messages. To disable verbose mode call transport.reset(), as the following example shows:

import { FingersCrossedTransport } from '@kristijorgji/winstojns-transport-fingers-crossed'
import { createLogger, transports } from 'winston';

const transport = new FingersCrossedTransport(new transports.Console(), {
  standardLevel: 'info',
  activationLevel: 'warn',
});

const logger = createLogger({ transports: [transport] });

logger.debug('Debug message will not be printed immediately');

logger.warn('Warn message will be printed immediately, together with the debug message above');
logger.debug('This debug message will be printed immediately as well');

transport.reset();

logger.debug('This debug message will not be printed');

FAQs

Package last updated on 29 Mar 2022

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