server-base-log

server base log wrapper using pino

Usage no npm install needed!

<script type="module">
  import serverBaseLog from 'https://cdn.skypack.dev/server-base-log';
</script>

README

server base pino logger

simple wrapper for pino used by server-base

js-standard-style build status downloads

usage

const log = require('server-base-log')(__filename, { optional pino options })

log.info('ok')

info, fatal, debug, error, trace and warn are bound to correct t.equal for convenience.

log options

All options are passed to pino

opt.pretty options are passed to pino.pretty constructor

default log options are

  safe: true,
  serializers: {
    req: pino.stdSerializers.req,
    res: pino.stdSerializers.res,
    q: pino.stdSerializers.req,
    r: pino.stdSerializers.res
  }

http request logging

Both log.info({ q, r }) and log.info({ req, res }) work.

env

setting process.env.LOG_PRETTY uses pino.pretty

setting process.env.LOG_LEVEL overrides the default log level which is debug

install

With npm do:

npm install server-base-log

license

Apache License, Version 2.0