Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

escalate

Package Overview
Dependencies
Maintainers
9
Versions
359
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escalate

logger / error reporting facade

  • 0.0.427
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

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

FAQs

Package last updated on 06 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc