Package Exports
- missionlog
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (missionlog) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
missionlog

Missionlog is an easy to use lightweight logging library that provides level-based logging and category filtering with minimal overhead.
Features
- Small footprint ~400 bytes with 0 dependencies
- Simple JSON configuration
- Filter by level
- Filter by named category
'system' | 'whatever'
- Flexible log event callback
- Style terminal output with chalk
- Send JSON to a cloud service like Loggly
- Log strings and objects to the browser's console
- API mirrors
console.log
logs objects and supports rest parameters - CommonJS module that works with node and browser through any bundler
- Includes TypeScript definitions so no
@types
needed
Install
npm install missionlog
Initialize
improt { log } from 'missionlog';
// Set the max level to log for arbitrary categories
// where INFO > WARN > ERROR > OFF
log.init({ loader: 'INFO', security: 'ERROR', system: 'OFF' }, (level, category, msg, params): void => {
// then log the way that works best for you
// * style terminal output with chalk
// * send JSON to a cloud logging service like Splunk
// * log strings and objects to the browser's console
console.log(`${level}: [${category}] `, msg, ...params);
});
Usage
Messages are logged when their level is equal to or greater than their category's level. Levels are ordered, OFF > ERROR > WARN > INFO
. Categories often correspond to the name of a system like "security" or "renderer". Each category has its own independent level. This provides granular control over your logs and helps keep them readable and uncluttered.
log.warn('loader', 'failed to load', url);
log.error('security', 'not authorized');
log.info('loader', 'asset loaded', { name, url });
// filtered since security's log level ERROR is greater than INFO
log.info('security', 'login successful');
// filtered since system's log level is turned OFF
log.error('system', 'eject the warp core', error);
// update log levels
log.init({ loader: 'ERROR', system: 'INFO' });
Result
About
Created by Ray Martone.