0.2.0 • Published 4 years ago

@proc/context-pino v0.2.0

Weekly downloads
8
License
MIT
Repository
-
Last release
4 years ago

Logging with context

A context aware logger using pino as a backend. Provides structured logging with little overhead.

import { createContext } from "@proc/context";
import { createLogger } from "@proc/context-pino";

const parent = createContext();
const getLogger = createLogger({
  base: {
    some: "fixed",
    values: true
  },
  ...otherPinoOptions
});

const child = parent.child();

const childLog = getLogger(child);

// will have the ctx id in the meta.
childLog.info("this is the child");

// bind some contextual values to this child
childLog.bind({ foo: "bar" });

// will have foo:bar in the meta
childLog.info("with added foo");

const parentLog = getLogger(parent);

parentLog.debug(
  "this will have the parent `ctx.id`, and not the added foo=bar"
);

// good practice, to release resources.
child.done();
parent.done();
0.2.0

4 years ago

0.1.36

5 years ago

0.1.35

5 years ago

0.1.34

5 years ago

0.1.32

5 years ago

0.1.29

5 years ago

0.1.28

5 years ago