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

suplogger

v0.0.2

Published

A simple logging library that provides log upload middleware.

Downloads

4

Readme

supLogger

A simple logging library that provides log upload middleware.

Getting help?

If you having problems? You can create an issue.

Installation

npm install suplogger

Usage

  • Require or import library
// ES6
import SupLogger from "suplogger";
// or commonjs
let SupLogger = require("suplogger");

let logger = new SupLogger();
  • Five log levels

The log level follows the sequence DEBUG, INFO, WARNING, ERROR, and NONE. The values are 0, 1, 2, 3, 4.

  • Sets the Log Level.

By selecting a level, you can see log information at that level and at all levels above that level. For example:

logger.setLogLevel(logger.WARNING);

then you can see logs in levels ERROR, and WARNING. The default value is NONE and the log is not output.

example:

// ES6
import SupLogger from "suplogger";
let logger = new SupLogger();
logger.setLogLevel(logger.WARNING);
logger.error("This is an error msg");

and you will see this on console

[2019-11-25 14:53:33] supLogger [ERROR] -  This is an error msg

if you want to remove or rename the prefix you can do this

logger.setLogLevel(logger.WARNING, "");
logger.error("This is an error msg");

//will output
[2019-11-25 14:53:33] [ERROR] -  This is an error msg

logger.setLogLevel(logger.WARNING, "[awsome SDK]");
logger.error("This is an error msg");

//will output
[2019-11-25 14:53:33] awsome SDK [ERROR] -  This is an error msg
  • Log template

Default template

[2019-11-25 14:53:33] supLogger [ERROR] -  This is an error msg

if you want

  • Outputs Log

example

logger.error("This is an error msg");
logger.warning("This is an warning msg");
logger.info("This is an info msg");
logger.debug("This is an debug msg");
  • Middleware

if want to upload all output logs , you can create an middle-ware to help you. For example:

/**
 * Method use accept a function as a parameter
 * Note:
 * 1. You can control whether the log is output by the next method.
 * 2. Selecting a level via setLogLevel, you can received log information at that level and at all levels above that level.
 **/
logger.use((logData, next) => {
  if (logData.type === "error") {
    // upload error log to your server and not output
    
  } else {
    // log will be output on console
		next();
  }
});

Tip: use middle-ware before call outputs function(such as logger.error、logger.info).

Complete example

// ES6
import supLogger from "suplogger";
let logger = new SupLogger();
// set log level
logger.setLogLevel(logger.WARNING);
// create middle-ware
logger.use((logData, next) => {
  if (logData.type === "error") {
    // upload error log to your server and not output
    
  } else {
    // log will be output on console
		next();
  }
});

// outputs log
logger.error("This is an error msg");
logger.warning("This is an warning msg");
logger.info("This is an info msg");
logger.debug("This is an debug msg");

you will see This is an error msg and This is an warning msg output on console tab.

License

check here.