Skip to content

ziazon/benchlogga

Repository files navigation

Benchlogga

Dependabot Status

A nodejs logging and benchmarking package.

Installation

npm i benchlogga
yarn add benchlogga

Usage

TypeScript

import { Benchlogga } from 'benchlogga';

const logger1 = new Benchlogga('SomeContext');
const logger2 = new Benchlogga('SomeOtherContext');

Javascript

var Benchlogga = require('benchlogga');

var logger = new Benchlogga('SomeContext');
var logger2 = new Benchlogga('SomeOtherContext');

Usage

Basic usage looks like this

logger.log('Hello from one of my modules');
logger.log('Some other event from the first module');
logger2.log('Hello from a differnet module');
setTimeout(() => logger.log('something that happened later'), 200);

The above would output something like this

[pid] 61380 - 01/28/2020, 12:28:45 AM  [SomeContext] Hello from one of my modules
[pid] 61380 - 01/28/2020, 12:28:45 AM  [SomeContext] Some other event from the first module +252.486 μs
[pid] 61380 - 01/28/2020, 12:28:45 AM  [SomeOtherContext] Hello from a different module
[pid] 61380 - 01/28/2020, 12:28:46 AM  [SomeContext] something that happened later +204.113158 ms

Benchlogga comes with 5 different message types

logger.log('string message')
logger.warn('string message')
logger.debug('string message')
logger.verbose('string message')
logger.error('string message', 'stack trace')
// or
logger.error(new Error('string message'))

The primary difference between them is the colors they display. For example, the above results in something that looks like this image

Roadmap

Currently it's mainly in the form of performance. can't have decent benchmarking if the logger is taking up too much time internally.