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

@cyberblast/logger

v0.0.9

Published

A simple logger for node

Readme

cyberblast logger

A simple logger for node

Build Status npm version

Usage

Sample usage:

const { Logger, severity } = require('@cyberblast/logger');
// Optional file path argument. Defaults to './logger.json'
const logger = new Logger('./logger.json');
// init will create log files and open file streams
await logger.init();
// define categories in config file or create them in code (or both)
logger.defineCategory('Sample');
// register additional custom log handlers
// attach callbacks to onError, onWarning, onInfo and onVerbose
logger.onWarning(log => {
  console.warn(`Ooops: ${log.message}. Details: ${JSON.stringify(log.data)}`);
});
// 'onLog' catches them all
logger.onLog(log => {
  console.log(`${log.severity}: ${log.message}`);
});
// 'on' allows to attach to custom filter rules (defined in config file)
logger.on('BackendError', log => {
  // sample function call not part of this repo:
  sendMailAlert(log);
});
// trigger some log events
logger.logVerbose('logger ready');
logger.logWarning('Do the Bartman', logger.category.Sample);
// or more explicit with some sample additional payload
logger.log({
  category: logger.category.BackendError,
  severity: severity.Error,
  message: 'storage capacity reached!',
  data: ['Drive C', {usage: '100%'}]
});
// close file streams gracefully
logger.close();

Configuration

Sample configuration:

{
  "categories": ["webserver"],
  "rules": [
    {
      "name": "all",
      "console": true
    },
    {
      "name": "error",
      "filePath": "./log/",
      "severity": "Error"
    },
    {
      "name": "webserver",
      "category": "webserver",
      "filePath": "./log/",
      "severity": "Info"
    }
  ]
}

Categories

optional, array of strings
List of predefined log categories. Configured categories will be available via category property at Logger class. However, preconfiguring categories is not mandatory to use log categories in logData and rules at all.

logger.logWarning('Do the Bartman', logger.category.Sample);

Rules

Rules define what to do with a certain log case.

  • name
    required, string
    Every rules needs a unique name. Logfiles will get the name of the rule. You can also hook into log events using the rule name, like:
    logger.on('BackendError', log => {
      sendMailAlert(log);
    });
    Where 'BackendError' would be the name of the rule. This only works only for rules with names not matching the reserved word "any" or a severity name.
  • category
    optional, string
    Log cases can have categories. If you specify a rule category, that rule will only be executed when rule category and log category match.
  • severity
    optional, string
    Log cases can have a severity. If you specify a rule severity, that rule will only be executed, if rule severity and log severity match or the log severity is higer. Also depends on 'severityOnly' rule property.
    If you don't specify a rule severity, that rule will run for all severities.
    You can also hook into log events using the severity name, like:
    logger.on('Warning', log => {
      sendMailAlert(log);
    });
  • severityOnly
    optional, boolean
    Defaults to false.
    Id severityOnly is set to true, rule severity and log case severity must exactly match to execute the rule. Otherwise the log case severity must match or be higher.
  • console
    optional, boolean
    Defaults to false. If console is set to true, log messages will be send to console.
  • filePath
    optional, string
    If filePath is set, Logger will create log files at that path. The log file name will have the format <rule.name>.log.
    Must be a valid path string according to Node Path module. It must point to a directory. If that directory does not exist, it will be created.
    Directory and logfile creation happens immediately upon Logger initialization.
    await logger.init();

Legal

Please take note of files LICENSE and CONTRIBUTING.

Credits

Thanks to Jacob Wright for his date format library.