@loglayer/context-manager-linked
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Linked Context Manager for LogLayer

NPM Version NPM Downloads TypeScript

A context manager for LogLayer that keeps context linked between parent and child loggers.

This means that changes to the context in the parent / child / child of child loggers will affect all loggers.

Installation

npm install @loglayer/context-manager-linked

Usage

import { LogLayer, ConsoleTransport } from "loglayer";
import { LinkedContextManager } from '@loglayer/context-manager-linked';

const parentLog = new LogLayer({
  transport: new ConsoleTransport({
    logger: console
  }),
}).withContextManager(new LinkedContextManager());

const childLog = parentLog.child();

childLog.withContext({
  module: 'users'
});

parentLog.withContext({
  app: 'myapp'
});

parentLog.info('Parent log');
childLog.info('Child log');

// Output includes: { module: 'users', app: 'myapp' }
// for both parentLog and childLog

Documentation

For more details, visit https://loglayer.dev/context-managers/linked

Package Sidebar

Install

npm i @loglayer/context-manager-linked

Homepage

loglayer.dev

Weekly Downloads

41

Version

1.0.4

License

MIT

Unpacked Size

19 kB

Total Files

9

Last publish

Collaborators

  • theo.gravity