npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@viva-eng/logger

v2.0.0

Published

A logger library for node.js

Downloads

28

Readme

An extremely light-weight logger for node.js

Install

$ npm install --save @viva-eng/logger

Basic Usage

import { Logger, ReadableFormat, StdoutOutput } from '@viva-eng/logger';

const logger = new Logger({
	format: ReadableFormat,
	output: new StdoutOutput(),
	colors: true,
	level: 'info'
});

logger.info('Hi there');

There are 6 logging methods: error, warn, info, verbose, debug, and silly.

Outputs

Any normal writable stream can be used as an output. It will receive messages to be logged. That's about all there is to say about that.

There are 2 outputs built in to the library. The StdoutOutput is just a thin wrapper around process.stdout. The other is the ClusterOutput which is designed to enable logging from workers in a clustered application. It works by passing the messages to be logged up to the master process using IPC, and the master process then logs the message to ensure that messages don't interlace with each other in unusual ways.

import { isMaster } from 'cluster';
import { Logger, ReadableFormat, StdoutOutput, ClusterOutput, ClusterOutputReceiver } from '@viva-eng/logger';

export let logger;

if (isMaster) {
	logger = new Logger({
		format: ReadableFormat,
		// Use whatever output you want here, this is where your logs will
		// end up for all workers and the master
		output: new StdoutOutput()
	});

	// Pass the logger into the receiver so it knows what to do with the messages
	const clusterOutputReceiver = new ClusterOutputReceiver(logger);
}

else {
	logger = new Logger({
		format: ReadableFormat,
		// This will forward all log messages up to the master
		output: new ClusterOutput()
	});
}

logger.info('Hi there! I work in all processes!');

Formats

A format is any object that implements the Format interface, which looks like this:

interface Format {
	format(level: string, message: string, meta?: object): string;
}

It takes in the message to be logged and formats it in whatever way you want, so long as the end result is a string.

There are two formats built in, the ReadableFormat which is a human-readable pretty print format (optionally with colors!) and the JsonFormat which outputs all your logs in JSON.