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

@popovmp/logger

v2.1.2

Published

Logger

Downloads

537

Readme

A simple Logger helper for nodejs

logger is a straightforward logger written in TypeScript. It logs to a single predefined file. When an option {tee: true} is given, logger shows colored messages in the console. If a log file is not defined, logger writes to the console only.

Homepage: https://github.com/popovmp/logger

Color outputs

Logger output light

Logger output dark

Installation

npm install @popovmp/logger

Usage

import {initLogger, logError, logSuccess, logWarning} from "./lib/logger.mts";

// Init logger
const loggerOptions = {
  filepath: "my/logger/path/log.txt",
  tee     : true,
  suppress: ["debug"]
};

initLogger(loggerOptions);

Examples

logInfo("Hello, World!");                           // => 2020-08-21 06:21:11 [INFO] Hello, World!
logInfo("GET index", "app::router");                // => 2020-08-21 06:21:11 [INFO] [app::router] GET index
logError("Ohh!", "bank::delete-account");           // => 2020-08-21 06:21:11 [ERROR] [bank::delete-account] Ohh!
logError(new Error("Err!"), "mission :: critical"); // => 2020-08-21 06:21:11 [ERROR] [mission :: critical] Err!
logText("So Long, and Thanks for All the Fish!");   // => So Long, and Thanks for All the Fish!

Last error

logger has two methods for getting and resetting the last logged error message: getLastError and resetLastError.

getLastError returns the last logged error message by the logError or logger.error methods.

You can reset the last error with the resetLastError method. When resetLastError is called without parameters, it sets the last error to undefined. resetLastError can be called with null to set the last error to null.

getLastError(); // undefined
logError("some eror");
getLastError(); // some error
resetLastError();
getLastError(); // undefined

Options

The filepath option sets the log filepath.

The init method accepts an options options parameter. It has two property tee: boolean and suppress: string[].

When tee is set to true, the logger doubles the message on the console.

The suppress parameter accepts a string[]. It suppresses the logging of the tags included.

The possible values are:

{
  "suppress": ["debug", "text", "info", "error", "success"]
}

Methods

logger exports the following methods:

/**
 * @param {LoggerOptions} loggerOptions
 * @returns {void}
 */
logger.init(loggerOptions);
/**
 * Logs a debug message to a log file
 *
 * @param {Error|object|string} message
 * @param {string} [sender]
 */
logDebug(message, sender);
/**
 * Logs a message to a log file
 *
 * @param {Error|object|string} message
 * @param {string} [sender]
 */
logInfo(message, sender);
/**
 * Logs an error to a log file
 *
 * @param {Error|object|string} message
 * @param {string} [sender]
 */
logEror(message, sender);
/**
 * Logs a success information to a log file
 *
 * @param {object|string} message
 * @param {string} [sender]
 */
logSuccess(message, sender);
/**
 * Logs an error to a log file
 *
 * @param { string } message
 */
logText(message);
/**
 * Logs a debug message to a log file
 *
 * @param {Error|object|string} message
 * @param {string} [sender]
 */
logger.debug(message, sender);
/**
 * Logs a message to a log file
 *
 * @param {Error|object|string} message
 * @param {string} [sender]
 */
logger.info(message, sender);
/**
 * Logs an error to a log file
 *
 * @param {Error|object|string} message
 * @param {string} [sender]
 */
logger.error(message, sender);
/**
 * Logs a success information to a log file
 *
 * @param {string} message
 * @param {string} [sender]
 */
logger.success(message, sender);
/**
 * Logs an error to a log file
 *
 * @param {string} message
 */
logger.text(message);

License

logger is free for use and modification. No responsibilities for damages of any kind.