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

reclogger

v1.2.2

Published

Simple logger for Node.js

Readme

recLogger - Simple Logger for Node.js

recLogger is a lightweight, flexible logging utility designed to provide easy and customizable logging to the console in Node.js. It supports various log levels, dynamic formatting, colorization, and customizable log patterns. This package is ideal for developers who want to improve the visibility of logs and easily manage the output for different logging purposes.

Warning: This library uses chalk for colorizing output. If you are using chalk in your project, you should use the same version in both places to avoid potential conflicts.

Table of Contents


Installation

To install the recLogger package, use npm:

npm install recLogger

Usage

Import the Logger

const recLogger = require("recLogger");

Create an Instance of the Logger

You can create an instance of the logger by passing an optional configuration object to the recLogger constructor. If no options are provided, the default settings will be used.

const logger = new recLogger({
  prefix: "App", // Prefix for log messages
  time: true, // Include timestamp in logs
  level: true, // Include log level in logs
  action: true, // Include action in logs
  color: true, // Enable color for log levels
  bold: true, // Enable bold text
  colors: {
    // Custom color mapping for each log level
    LOG: "green",
    ERROR: "red",
    WARN: "yellow",
    INFO: "cyan",
    DEBUG: "gray",
    SUCCESS: "green",
  },
  pattern: "[{prefix}] ({time}) ({level}) >> {action} | {text}", // Custom log message pattern
});

Log Messages

The logger supports several logging methods corresponding to common log levels:

1. log(action, text, level, color)

Logs a message with a custom action, message text, log level, and optional color. If no color is provided, the default level color will be used.

//with action
logger.log("DataProcessing", "Started processing data", "INFO", "cyan");

//only text
logger.log("hello world!");

2. error(action, text)

Logs an error message in red.

logger.error("DatabaseConnection", "Failed to connect to the database");

3. warn(action, text)

Logs a warning message in yellow.

logger.warn("MemoryUsage", "Memory usage is high");

4. info(action, text)

Logs an informational message in cyan.

logger.info("FileUpload", "File upload completed successfully");

5. debug(action, text)

Logs a debug message in gray.

logger.debug("APIRequest", "Request payload: { id: 1 }");

6. success(action, text)

Logs a success message in green.

logger.success("Authentication", "User login successful");

Customization

You can customize the behavior of the logger by configuring the following options:

  • prefix (string): Adds a prefix to each log message (default is 'LOG').
  • time (boolean): Includes the timestamp in the log message (default is true).
  • level (boolean): Includes the log level in the message (default is true).
  • action (boolean): Includes the action in the log message (default is true).
  • color (boolean): Whether to colorize the log messages (default is true).
  • bold (boolean): Whether to use bold text for logs (default is true).
  • colors (Object): Custom color mapping for each log level (default colors provided).
  • pattern (string): A string format pattern to customize the structure of log messages.

Available colors: - black - red - green - yellow - blue - magenta - cyan - white - blackBright (alias: gray, grey) - redBright - greenBright - yellowBright - blueBright - magentaBright - cyanBright - whiteBright

Available placeholders: - {prefix} - the prefix of the log. - {time} - the timestamp of the log. - {level} - the log level (e.g., LOG, ERROR, INFO). - {action} - the action being logged. - {text} - the main log message.

For example, if you wanted a custom log pattern like this:

[Prefix] Time: [Time] Level: [Level] - Action: [Action] => Message: [Text]

You could set the pattern like this:

const logger = new recLogger({
  pattern:
    "[{prefix}] Time: [{time}] Level: [{level})] - Action: [{action}] => Message: [{text}]",
});

Example

const recLogger = require("recLogger");
const logger = new recLogger();

logger.log("FileUpload", "Uploading file to server", "INFO");
logger.error("ServerError", "Internal server error occurred");
logger.warn("HighTraffic", "High traffic detected");
logger.debug("Request", "GET /api/data");
logger.success("Payment", "Payment processed successfully");

Methods Overview

  • log(action, text, level, color) - General logging method for any level.
  • error(action, text) - Logs an error message.
  • warn(action, text) - Logs a warning message.
  • info(action, text) - Logs an informational message.
  • debug(action, text) - Logs a debug message.
  • success(action, text) - Logs a success message.

Example Output

[App] (10:30:21) (INFO) >> FileUpload | Uploading file to server
[App] (10:30:21) (ERROR) >> ServerError | Internal server error occurred
[App] (10:30:21) (WARN) >> HighTraffic | High traffic detected
[App] (10:30:21) (DEBUG) >> Request | GET /api/data
[App] (10:30:21) (SUCCESS) >> Payment | Payment processed successfully

License

The recLogger library is licensed under the MIT License.


Contributing

For more details or contributions, please refer to the GitHub repository.