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

@voodoo.io/fast-logger

Package Overview
Dependencies
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voodoo.io/fast-logger

Fast logger with a buffer

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
7
Weekly downloads
 
Created
Source

fast-logger

Fast logger with buffer


npm version

Purpose

Simple fast logger which contain a LRU cache to avoid big spike to the stack of logs.

Compatibility

Supported and tested : >= 8.10

VersionSupportedTested
12.xyesyes
10.xyesyes
9.xyesyes
8.xyesyes

Installation

$ npm install @voodoo.io/fast-logger --save

Usage

You must set in your var env: APP_NAME
Accepted format:

  • string
  • array
  • object
  • Error

You can provide a var env: LOG_LEVEL. For example, setting "warn" will disabled trace, debug and info logs. Accepted values:

  • trace
  • debug
  • info (default if wrong or none defined)
  • warn
  • error

Basic Usage

const logger = require('@voodoo.io/fast-logger');

logger.info('My log', {key: 'value'}, [0,1,2]);
logger.error('My error');
// output:
// {"app":"MyAppName","time":"2020-02-11T16:18:07.731Z","level":"info","msg":"My log","key":"value","data_0":[0,1,2]}
// {"app":"MyAppName","time":"2020-02-11T16:18:07.731Z","level":"error","msg":"My error"}

Buffer

The logger has a buffer of 100 ms by default if the logs are exactly the same (same objects, not same JSON-equivalent object) More information at: https://www.npmjs.com/package/lru-cache

const logger = require('@voodoo.io/fast-logger');

// It will log only one time `My log` and `My error`
for (let i = 0; i < 100; i++) {
    logger.info('My log');
    logger.error('My error');
}

Options

You can disable the logger by calling the function setCacheTTL with a negative integer value or you can customize the TTL of the items in the cache

const logger = require('@voodoo.io/fast-logger');

// cache is disable
logger.setCacheTTL(-1);

// buffer of 1 sec in the cache
logger.setCacheTTL(1000);

Test

$ npm test

Coverage report can be found in coverage/.

Keywords

FAQs

Package last updated on 17 Feb 2020

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