2.1.0 • Published 5 years ago

@kofile/production-pino-log-formatter v2.1.0

Weekly downloads
38
License
MIT
Repository
-
Last release
5 years ago

Production Pino Log Formatter

NPM version Build Status semantic-release

Transport for pino

Takes

{
  "level": 30,
  "time": 1531171074631,
  "msg": "hello world",
  "pid": 657,
  "hostname": "Davids-MBP-3.fritz.box",
  "v": 1,
  "prop1": "hello",
  "prop2": 42
}

and emits

2018-07-09T21:17:54Z [INFO] hello world, prop1={hello}, prop2={42}

Install

yarn add @kofile/production-pino-log-formatter

Usage

const pino = require("pino");
const { format } = require("@kofile/production-pino-log-formatter");

const logger = pino(format());

How

In addition to configuration options, Pino accepts a destination stream to emit log entires to. This library provides a transform stream as the target which can rewrite the log entries before they're emitted to stdout.

Note that this is an in-process transport.

Pino discourages this:

Ideally, a transport should consume logs in a separate process to the application. Using transports in the same process causes unnecessary load and slows down Node's single threaded event loop.

This approach is still likely faster than using @kofile/log, though I don't have benchmarks to support that assertion.

Notes

  • No ANSI color codes. Ever.