kleio
Functional logger which purpose is to simplify debugging and error management during production and development phases. In essence kleio provides the common error-level/severity system based on npm
logging levels. Kleio provides a simple and minimal API in order to send debugging information to a remote host with ease.
Installation
npm install kleio --save
Usage
Note: The logger is invoked when last parameter has be acquired.
Create a reusable functional logger
let log = /* post implementation */; /* severity *//* meta-data */;// Or;
Log object
Passed to the post
function parameter.
Log time: String message: String severity: Number meta: Object
Log levels
Levels are defined using integer values 0(high) to 6(low).
ERROR: 0 WARN: 1 INFO: 2 VERBOSE: 3 DEBUG: 4 SILLY: 5 SILENT: 6
A simple use case
; const postFunction = { ;} let log = postFunction; 'Hello log!' 'some': 'additional data that might be valuable.'; 'A test log'; 'Perform something after post' ; ;
A more advanced use case
// services/log.js; const env = processenvNODE_ENV || 'development'; const developmentLogger = { return ;};const productionLogger = { return ;}; { if responsestatus >= 200 && responsestatus < 300 return response; else return Promise; } const error = ;const warn = ;const log = ;const info = ;const debug = ;const verbose = ; // antoher-file.js; ; ; ; ; ;
Post directly
; ; // or /* environment */ /* message */ /* severity */ /* meta-data */ ;
Tests
npm test
License
MIT