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

loglevel-plugin-prefix

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loglevel-plugin-prefix

Plugin for loglevel message prefixing

  • 0.8.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is loglevel-plugin-prefix?

The loglevel-plugin-prefix npm package is a plugin for the loglevel logging library that allows you to add customizable prefixes to your log messages. This can be useful for adding context to your logs, such as timestamps, log levels, or custom tags.

What are loglevel-plugin-prefix's main functionalities?

Basic Prefixing

This feature allows you to add a basic prefix to your log messages. By default, it adds the log level as a prefix.

const log = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
prefix.apply(log);
log.info('This is an info message');

Custom Prefix Format

This feature allows you to customize the format of the prefix. You can include a timestamp, log level, and logger name in the prefix.

const log = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
prefix.apply(log, {
  template: '[%t] %l (%n):',
  timestampFormatter: date => date.toISOString(),
  levelFormatter: level => level.toUpperCase(),
  nameFormatter: name => name || 'global'
});
log.info('This is an info message');

Custom Prefix Function

This feature allows you to define a custom function to format the prefix. This gives you complete control over how the prefix is generated.

const log = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
prefix.apply(log, {
  format(level, name, timestamp) {
    return `${timestamp} [${level}] ${name}:`;
  }
});
log.info('This is an info message');

Other packages similar to loglevel-plugin-prefix

Keywords

FAQs

Package last updated on 26 Jan 2018

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