1.0.6 • Published 4 months ago

pino-update-transport v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

pino-update-transport

Description

Pino transport to allow JSON lines updates before final output.

Example

On first update:

  • will search for error.type field
  • check if value contains error and disconnect
  • if matched, will set level attribute to 40

On second update:

  • will search for msg field
  • check if value contains "error"
  • if matched, will set isError attribute as true
const pino = require('pino');

const updates = [
  {
    path: 'error.type',
    contains: ['error', 'disconnect'],
    merge: { level: 40 },
  },
  {
    path: 'msg',
    contains: ['error'],
    merge: { isError: true },
  },
];

const logger = pino({
  level: 'info',
  transport: {
    target: 'pino-update-transport',
    options: {
      updates,
    },
  },
});

logger.error({ error: { type: 'error as disconnect' } }, 'error happened');

With output as:

{"level":40,"time":1706145844495,"pid":9319,"hostname":"Mitjas-MBP","error":{"type":"error as disconnect"},"msg":"error happened","isError":true}

Development

pnpm build
pnpm test
1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago