@quim/mlog
v1.0.0
Published
a minimal logging lib for NodeJS
Downloads
2
Readme
mlog
a minimal logging lib for NodeJS
instalation
npm i -S @quim/mlog
interface
import log from 'mlog'
const logger = log(origin: string)
and exposes 2 methods
- info(msg: string | object)
- error(msg: string | object)
example
import mlog from 'mlog';
const logger = mlog('my-app')
....
logger.info('hello there!')
// output a string
{"pid": 88064, "os": {...}, "memory": {...}, "type": "info", "timestamp": 1574819112182, "msg": "hello there!", "origin": "my-app"}
// or you can pass an object instead
logger.info({headers: [{'content-type': 'application/javascript'}], body: {hello: 'world'}})
// output a string
{
"pid": 35573,
"os": { loadavg, platform, release, uptime, hostname},
"memory": { rss, heapTotal, heapUsed, external },
"type": "info",
"timestamp": 1574964980420,
"msg": {
"headers": [
{
"content-type": "application/javascript"
}
],
"body": {
"hello": "world"
}
},
"origin": "my-app"
}