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 🙏

© 2026 – Pkg Stats / Ryan Hefner

2b-logger

v0.0.3

Published

A simple JS logger

Readme

2b-logger

A simple to use JS logger.

Installation

	npm install 2b-logger

If you want to save the install in package.json:

	npm install --save 2b-logger

Or

	npm install --save-dev 2b-logger

Basic usage

The basic usage for this logger is the following:

	const loggerConstructor = require ( "2b-logger" );
	const logger = loggerConstructor ();
	logger.info("A nice info message");

Or, in a simplified version:

	const logger = require ( "2b-logger" ) ();
	logger.info("A nice info message");

The import require ( "2b-logger" ) will return a constructor function that takes, optionally, a configuration object.

The default options are:

	{
		"level": "info",
		"noColor": false,
		"timestampFormat": "YYYY-MM-DD @ HH:mm:ss:ms"
	}

Options

The options object can receive the following configurations:

level (string, default: info)

The level indicates which messages will be logged and which will be discarded. The accepted values are trace, debug, info, warn and error.

The following table displays which messages will be logged, depending on the configured level:

Messages with the success level are considered to be of info level, but they have a different render style.

noColor (boolean, default: false)

This boolean option indicates the logger that no color should be added to rendered messages.

Even if logged messages are colored, they will have the color removed, if noColor was set as true.

Example:

	const logger = require ( "2b-logger" ) ({ noColor: true });
	const chalk = require ( "chalk" );
	logger.info ( chalk.cyan ( "A cyan message" ) );

In this case, the redered message will not have colors.

timestampFormat (string, default: YYYY-MM-DD @ HH:mm:ss:ms)

This is the timestamp format to be used when rendering messages. The accepted format can be seen here.

API

Once a logger has been created, the following methods are available in it:

logger.trace ( msg1, msg2, ... )

Logs the messsages using trace level.

logger.debug ( msg1, msg2, ... )

Logs the messsages using debug level.

logger.info ( msg1, msg2, ... )

Logs the messsages using info level.

logger.success ( msg1, msg2, ... )

Logs the messsages using success level.

logger.warn ( msg1, msg2, ... )

Logs the messsages using warn level.

logger.error ( msg1, msg2, ... )

Logs the messsages using error level.

ℹ️ - About log parameters

  • The logger will ignore null parameters.
  • All other parameters will be converted to string, using .toString ( ).
    • If, and only if, the result string is neither null nor empty it will be appended to the message, using a space character as separator.

Example output

The following code:

const logger = require ( "../src/index.js" ) ({
	level: "trace"
});

logger.trace ( "trace", "msg" );
logger.debug ( "debug", "msg" );
logger.info ( "info", "msg" );
logger.success ( "success", "msg" );
logger.warn ( "warn", "msg" );
logger.error ( "error", "msg" );

Will produce the following output:

sample output