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 🙏

© 2024 – Pkg Stats / Ryan Hefner

escalate

v0.0.427

Published

logger / error reporting facade

Downloads

1,115

Readme

Escalate

npm version

A generic logger / error reporting facade. Can apply different loggers to different logging contexts, and escalate logging into runtime errors.

It is said that most problems in the computer science can be solve by adding the right amount of indirection. Escalate provides a way (of inderction) to intervene and decide what to do with logging and throwing errors. This allows you test how non functional code behaves.

Usage

In your code:

Logging

import {getMailBox} from 'escalate';
const MAILBOX = getMailBox(context);

where context can be anything you want to use to identify the logging events from that specific instance. Usually, that would be a string namespace in dot notation, like 'my.beautiful.library'. Naming the instance MAILBOX is a code convention that will allow future tools to filter some logging invocation from the code before producing a production version. then issue reports like so:

MAILBOX.error(`Something unexpected happened: ${message}`);

or like so:

MAILBOX.post('error', misMatchMessage(errorContext,fieldDef,fieldDef.defaults(),path));

supported logging levels: debug, info, warn, error, fatal' By default, the debug level is ignored, and the error and fatal levels will throw an error.

Configuring

You can configure the behavior by using the config method:

import {config} from 'escalate';
config(configuration);

The configuration object may have any of 4 optional methods:

{
  loggerStrategy : (context) => logger
  panicStrategy : (context) => panic
  logThresholdStrategy : (context) => logThreshold
  panicThresholdStrategy : (context) => panicThreshold
}

The logger type has 4 mandatory handler methods, nameddebug, info, warn, error'. By default, this will be used:

let logger = {
  error : (...params) => console.error(...params),
  warn : (...params) => console.warn(...params),
  info : (...params) => console.info(...params),
  debug : (...params) => console.info(...params) // some environments don't have console.debug
};

The panic type is a method that will be called whenever a logging event that passes the panic threshold occures. for example:

function panic(...params){
  throw new Error(params.join(' '));
}

logThresholdStrategy and panicThresholdStrategy are methods that accept a context and return a logging level (string). Any log event that is below the logging threshold returned by logThresholdStrategy will be ignored at runtime, while any log event that is equal or above the logging threshold returned by panicThresholdStrategy will escalate to the panic returned by panicStrategy.

No Semantic verisoning yet (alpha phase)

This software is in alpha version phase, and so does not respect semantic versioning yet. Breaking changes may occur between patch versions.

Develop

  • to install
npm install
  • to test and debug
npm start

and then open browser at http://localhost:8080/webpack-dev-server/test

  • To build for release: $ npm run build:src

License

We use a custom license, see LICENSE.md