1.0.0 • Published 4 years ago

@quim/mlog v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

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"
}

ISC License (ISC)