Socket
Socket
Sign inDemoInstall

triple-beam

Package Overview
Dependencies
0
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

triple-beam

Definitions of levels for logging purposes & shareable Symbol constants.


Version published
Maintainers
2
Weekly downloads
8,053,393
decreased by-12.92%

Weekly downloads

Package description

What is triple-beam?

The triple-beam npm package is a module that provides constants for the Winston logging library, which is widely used in Node.js applications for logging purposes. It includes log levels, colors, and configuration utilities that can be used to customize and format log messages.

What are triple-beam's main functionalities?

Log Levels

Triple-beam provides a set of predefined log levels that can be used to categorize log messages by their severity. This allows for filtering and controlling the flow of log output.

{"levels": {"info": 0, "warn": 1, "error": 2, "verbose": 3}}

Configurable Log Properties

It allows for the configuration of log properties using symbols, which ensures that log metadata is not overwritten when multiple transports are used in Winston.

{"MESSAGE": Symbol.for('message'), "LEVEL": Symbol.for('level')}

Custom Log Formats

Triple-beam provides constants that can be used to create custom log formats in Winston, allowing developers to define how log messages should be structured and presented.

const { format } = require('winston');
const { SPLAT, LEVEL, MESSAGE } = require('triple-beam');

const customFormat = format((info, opts) => {
  info[SPLAT] = info[SPLAT] || [];
  info[LEVEL] = info[LEVEL] || 'info';
  info[MESSAGE] = `Custom format: ${info.message}`;
  return info;
});

Other packages similar to triple-beam

Readme

Source

triple-beam

Definitions of levels for logging purposes & shareable Symbol constants.

Usage

const { LEVEL } = require('triple-beam');
const colors = require('colors/safe');

const info = {
  [LEVEL]: 'error',
  level: 'error',
  message: 'hey a logging message!'
};

// Colorize your log level!
info.level = colors.green(info.level);

// And still have an unmutated copy of your level!
console.log(info.level === 'error');  // false
console.log(info[LEVEL] === 'error'); // true

Tests

Tests are written with mocha, assume, and nyc. They can be run with npm:

npm test
LICENSE: MIT
AUTHOR: Charlie Robbins

Keywords

FAQs

Last updated on 10 Jul 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc