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

reactjs-logger

v1.0.1

Published

A lightweight and versatile logger for structured and consistent logging in Node.js and browser environments. Includes human-readable timestamps and supports multiple log levels.

Downloads

134

Readme

Logger Package

A lightweight and versatile logger for structured and consistent logging in Node.js and browser environments. Includes human-readable timestamps and supports multiple log levels.

Features

  • Human-Readable Timestamps: Logs include precise timestamps for better traceability.
  • Flexible Log Levels: Supports info, warn, and error log levels.
  • Environment-Based Control: Adjusts logging behavior for development and production environments.

Installation

Install the package via npm:

npm install reactjs-logger

Usage

Importing the Logger

import log from "reactjs-logger";

Logging Examples

1. Log with Explicit Level

log("info", "This is an informational message.");
log("warn", "This is a warning message.", { usage: "85%" });
log("error", "An error occurred!", new Error("Sample error"));

2. Log with Default Level (info)

If the log level is omitted, the default is info:

log("Task completed successfully.", { taskId: 123 });

API Documentation

log(level: LogLevel | unknown, ...messages: unknown[]): void

Logs messages with a specified log level. If no valid log level is provided, the function defaults to info.

Parameters

  • level: (LogLevel | unknown)
    The log level ("info", "warn", or "error"). If this doesn't match a valid log level, it is treated as part of the message.

  • ...messages: (unknown[])
    The messages to log. Can include strings, objects, or any data type.

Example

log("info", "Application started.");
log("warn", "High memory usage detected.", { usage: "95%" });
log("error", "Unhandled exception occurred.", new Error("Sample error"));

Log Levels

| Level | Description | Example Usage | | ------- | -------------------------------- | ------------------------------------- | | info | General informational messages. | log("info", "Server started."); | | warn | Warnings about potential issues. | log("warn", "Disk usage high."); | | error | Errors or critical issues. | log("error", "Failed to connect."); |

Environment Configuration

Control logging behavior using environment variables:

  • NEXT_PUBLIC_LOGGER: Enables or disables logging. Set to true to enable logging.
  • NODE_ENV: Adjusts log level filtering based on the environment.
    • development: Logs all levels (info, warn, error).
    • production: Logs only warn and error levels.

Example .env File

NEXT_PUBLIC_LOGGER=true
NODE_ENV=production

Production Considerations

  1. Minimize Logs: In production, only log necessary levels (warn and error) to avoid performance degradation.
  2. Use Centralized Logging: Route logs to tools like AWS CloudWatch, Datadog, or Logstash for better observability.
  3. Avoid Sensitive Data: Ensure no sensitive information (like API keys or passwords) is logged.