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

log-helper

v1.0.0

Published

A small module to simplify logging

Downloads

225

Readme

Log Helper

This highly configurable package offers some functions which help you to understand your console logs by colorizing the output and providing the current date.

Installation

npm i log-helper --save

Usage

There are 6 functions available:

  • success(message, config)
  • info(message, config)
  • status(message, config)
  • warning(message, config)
  • error(message, config)
  • setConfig(config)

Each logged message looks like the following:

currentDate + prependString + message;

All of this output is colored via the chalk package, and the color of the output is the main difference of all this functions.

Example

const logHelper = require('log-helper)';
const http = require('someFancyHttpModule');

logHelper.status('Start fetching http data');
http.get('https://jsonplaceholder.typicode.com/posts/1').then((data) => {
    logHelper.success('Successfully fetched http data');
    if (data) {
        logHelper.info(`The data is: ${data}`);
    } else {
        logHelper.warning(`Empty data`);
    }
}).catch((error) => {
    logHelper.error(`Oh no! Something went wrong while fetching http data: ${error}`);
});

Configuration

Every function has the following configuration options:

  • chalk: This is a string which defines the color of the message output.
  • dateChalk: This is also a string, which defines the color of the current date.
  • prependString: You can provide a string which automatically gets inserted between the current date and the message.
  • dateFormat: This string defines in which format the date of the output gets logged.

NOTE: You do not have to configurate any of this options yourself, only if you don't like the default configuration.

To configurate the chalkor the dateChalk option, you do not have to directly use the chalk package. Instead, provide a string where each chalk option is separated with a dot. For example, if you want your message in a green, bold font, use the following as a config object:

{
    chalk: 'bold.green'
}

To what style options are available, have a look at the chalk package.

The date formatting work is done by the dateformat package. Have a look at the documentation to see the available format options.

There are two ways to configurate this package. You can either provide a config object as a second parameter in each if the five logging functions, or use the setConfig method. But there is a difference between these two ways: The first way will only configurate the message provided as the first parameter, while the second way will overwrite the default configuration.

const logHelper = require('log-helper');

// will be logged in the default green font
logHelper.success('It works!');

// will be logged in blue font
logHelper.success('It works!', {
    chalk: 'blue'
});

// will be logged in the default green font
logHelper.success('It works');

// now the default chalk setting for the success function will be overwritten
logHelper.setConfig({
    success: {
        chalk: 'bgBlack.white'
    }
});

// will be logged in a white font on black background
logHelper.success('It works');

// it is also possible to configurate multiple output functions at one time
logHelper.setConfig({
    error: {
        prependString: 'Oh no, there was an error: '
    },
    status: {
        chalk: 'bgWhite.bold.cyan',
        dateFormat: 'mm/dd/yyyy HH:MM:ss'
    },
    info: {
        dateChalk: 'bold.gray',
        prependString: '(Info): '
    }
})

If you use the setConfig method, the configuration will be used in your whole project:

// firstFile.js
const logHelper = require('log-helper');

logHelper.setConfig({
    success: {
        chalk: 'yellow'
    }
});

// secondFile.js
const logHelper = require('log-helper');

// will be logged in a yellow font
logHelper.success('It works!');

If you want to disable logging, use the setConfig method:

const logHelper = require('log-helper');

logHelper.setConfig({
    disableLogging: true
});

// will not be logged
logHelper.error('ERROR!');

Default configuration

This is the default configuration of all five logging functions.

{
    disableLogging: false,
    success: {
        chalk: 'green',
        dateChalk: 'white',
        prependString: null,
        dateFormat: "dd.mm.yyyy HH:MM:ss l'ms'"
    },
    info: {
        chalk: 'cyan',
        dateChalk: 'white',
        prependString: null,
        dateFormat: "dd.mm.yyyy HH:MM:ss l'ms'"
    },
    status: {
        chalk: 'gray',
        dateChalk: 'white',
        prependString: null,
        dateFormat: "dd.mm.yyyy HH:MM:ss l'ms'"
    },
    warning: {
        chalk: 'bold.yellow',
        dateChalk: 'white',
        prependString: null,
        dateFormat: "dd.mm.yyyy HH:MM:ss l'ms'"
    },
    error: {
        chalk: 'green',
        dateChalk: 'bold.bgWhite.red',
        prependString: 'An error occured: ',
        dateFormat: "dd.mm.yyyy HH:MM:ss l'ms'"
    }
}