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

custom-log-js

v1.1.0

Published

A customizable logging utility for Node.js and browser environments.

Readme

Smart Logger

License Version Downloads

A lightweight and customizable logger for both browser and Node.js environments. Supports log levels (trace,debug, info, warn, error) and colored output.

Features

  • Universal: Works in both browser and Node.js environments.
  • Custom Log Levels: Set the minimum log level to control output.
  • Colored Output: Logs are color-coded for better readability.
  • Lightweight: No external dependencies.

Installation

Install the package via npm:

npm install custom-log-js

Or via yarn:

yarn add custom-log-js

Usage

Basic Usage

const Logger = require("custom-log-js");

// Create a logger instance
const logger = new Logger({ logLevel: "info" });

// Log messages
logger.trace("This is a tarce message"); // Won't log (logLevel is 'info')
logger.debug("This is a debug message"); // Won't log (logLevel is 'info')
logger.info("This is an info message"); // Will log
logger.warn("This is a warning message"); // Will log
logger.error("This is an error message"); // Will log

Set Log Level Dynamically

You can change the log level at runtime:

logger.setLogLevel("debug"); // Now debug logs will be shown
logger.debug("This is a debug message"); // Will log

Smart Logger Instance

new Logger(options)

Creates a new logger instance.

  • options (Object):
    • logLevel (String): Minimum log level to display. Default: 'info'.
    • Possible values: 'trace', 'debug', 'info', 'warn', 'error'.

Methods

  • logger.trace(message, ...args): Logs a trace message.
  • logger.debug(message, ...args): Logs a debug message.
  • logger.info(message, ...args): Logs an info message.
  • logger.warn(message, ...args): Logs a warning message.
  • logger.error(message, ...args): Logs an error message.
  • logger.setLogLevel(level): Sets the minimum log level.

Examples

Browser Example

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Logger Test</title>
    <script src="https://unpkg.com/custom-log-js/dist/logger.js"></script>
    <script>
      const logger = new Logger({ logLevel: "debug" });

      logger.trace("This is a trace message");
      logger.debug("This is a debug message");
      logger.info("This is an info message");
      logger.warn("This is a warning message");
      logger.error("This is an error message");
    </script>
  </head>
  <body>
    <h1>Check the console for logs!</h1>
  </body>
</html>

Node Example

const Logger = require('custom-log-js');
const logger = new Logger({ logLevel: 'warn' });

logger.trace('This is a trace message'); // Won't log
logger.debug('This is a debug message'); // Won't log
logger.info('This is an info message'); // Won't log
logger.warn('This is a warning message'); // Will log
logger.error('This is an error message'); // Will log

Building the Package

If you want to build the package locally:

1. Clone the repository:

git clone https://github.com/pratyushbehera/smart-logger.git
cd smart-logger

2. Install dependencies:

npm install

3. Build the package:

npm run build

This will generate a dist folder containing the bundled and minified files.


Contributing

Contributions are welcome! Follow these steps:

1. Fork the repository.

2. Create a new branch:

git checkout -b feature/your-feature

3.Make your changes and commit them:

git commit -m "Add your feature"

4.Push to the branch:

git push origin feature/your-feature

5.Open a pull request.


License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

If you find this package useful, please consider giving it a ⭐️ on GitHub.

For issues or feature requests, please open an issue on the GitHub repository.


Enjoy logging! 🚀