0.2.0 • Published 5 years ago

@proc/context-pino v0.2.0

Weekly downloads
8
License
MIT
Repository
-
Last release
5 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

5 years ago

0.1.36

6 years ago

0.1.35

6 years ago

0.1.34

6 years ago

0.1.32

6 years ago

0.1.29

6 years ago

0.1.28

6 years ago