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

@falaksingh/logger

v1.0.0

Published

A lightweight logger utility

Readme

Logger Utility

A simple and customizable logging utility for Node.js applications. This logger provides different methods for logging errors, info, and success messages with optional features like error trace, line separators, terminal colorization, and writing logs to disk.

Installation

To use this logger in your project, you can install it via npm:

npm install @falaksingh/logger

Usage:

Importing the Logger

First, import the Logger class from the module:

import Logger from '@falaksingh/logger';

Creating a Logger Instance

You can create an instance of the Logger class with optional configuration:

const logger = new Logger({
  parseErrorInstance: true,
  enableLineSeparator: true,
  enableTerminalColorizer: true,
  writeToDisk: { enable: true, errorfilePath: 'logs/error.log', infoFilePath: 'logs/info.log' },
});

Logging Messages

The logger provides several methods for logging different types of messages:

Error Logging

Logs error messages. If parseErrorInstance is set to true, it will also log the file path and line number where the error occurred.

logger.error(new Error('This is an error message'));
logger.error('This is a plain text error message');

Info Logging

Logs informational messages.

logger.info('This is an info message');

Success Logging

Logs success messages.

logger.success({ type: 'Fiat', model: '500', color: 'white' });

Configuration Options

The Logger class accepts the following configuration options:

  • parseErrorInstance (boolean): If set to true, the logger will include the file path and line number in error logs. Default is false.
  • enableLineSeparator (boolean): If set to true, the logger will add a line separator after each log message. Default is false.
  • enableTerminalColorizer (boolean): If set to true, log messages will be colorized in the terminal. Default is false.
  • writeToDisk (object): If enabled, logs will be written to disk. Default is disabled.
    • errorfilePath (string): Path for storing error logs. Default is 'logs/error.log'.
    • infoFilePath (string): Path for storing info logs. Default is 'logs/info.log'.
    • enable (boolean): Enables writing logs to disk. Default is false.

Additional Features

Writing Logs to Disk

If writeToDisk.enable is set to true, error and info logs will be written to their respective files.

const logger = new Logger({
  writeToDisk: { enable: true, errorfilePath: 'logs/error.log', infoFilePath: 'logs/info.log' },
});

Terminal Colorization

If enableTerminalColorizer is set to true, logs will be styled with colors for better readability.

const logger = new Logger({ enableTerminalColorizer: true });

Example

Here is a complete example of how to use the logger:

import Logger from '@falaksingh/logger';

const logger = new Logger({
  parseErrorInstance: true,
  enableLineSeparator: true,
  enableTerminalColorizer: true,
  writeToDisk: { enable: true, errorfilePath: 'logs/error.log', infoFilePath: 'logs/info.log' },
});

logger.error(new Error('This is an error message'));
logger.error('This is a plain text error message');
logger.info('This is an info message');
logger.success({ type: 'Fiat', model: '500', color: 'white' });

Dependencies

This logger uses the @falaksingh/sketch package for styling the log messages.