1.0.0 • Published 3 years ago

debug-aggregator v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Debug Aggregator

Originally make for gradual improvement over console.log or debug in order to be used for log aggregator such as datadog.

Usage

const { compactLogInfo, compactLogWarn, compactLogError, compactDebug } = require("debug-aggregator")
compactLogInfo("info log")
compactLogWarn("warn log")
compactLogError("error log", 1)
const debugData = compactDebug("data:*")
debugData.info("I am info")
debugData.warn("I am warn")
debugData.error("I am error")
debugData.info("I am info", {something: "something"}, [])
compactLogInfo("done", "yeah")

result with export DEBUG=data:dew

"info log"
"warn log"
["error log",1]
{ key: 'data:*', log: '"I am info"' }
{ key: 'data:*', log: '"I am warn"' }
{ key: 'data:*', log: '"I am error"' }
{ key: 'data:*', log: '["I am info",{"something":"something"},[]]' }
["done","yeah"]

TODO

test it with JEST maybe

Referred to package

https://www.npmjs.com/package/safe-json-stringify (MIT License) 1.2.0 https://www.npmjs.com/package/debug (MIT License) 4.3.2