Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved global instance #10

Merged
merged 1 commit into from
Nov 4, 2023
Merged

feat: improved global instance #10

merged 1 commit into from
Nov 4, 2023

Conversation

noomorph
Copy link
Collaborator

@noomorph noomorph commented Nov 4, 2023

Adds bunyamin and nobunyamin named exports.

These root logger instances receive a shared threadGroups config option to facilitate traceEventStream creation by the end consumer of Bunyan logs. Libraries using bunyamin can push their thread groups (id, name, maxConcurrency) to provide a better experience when browsing the final trace log in Chrome Tracing or Perfetto UI.

import bunyamin from 'bunyamin';

bunyamin.threadGroups.push({ id: 'mylib.emitter', displayName: 'Emitter (mylib)' });

And then, the final consumer:

import { createLogger } from 'bunyan';
import bunyamin, { traceEventStream } from 'bunyamin';

bunyamin.logger = createLogger({
  name: 'my-app',
  streams: [
    {
      level: 'trace',
      stream: traceEventStream({
        filePath: '/path/to/trace.json',
        loglevel: 'trace',
        threadGroups: [...bunyamin.threadGroups, { id: 'custom-thread' }],
      }),
    }
  ],
});

@noomorph noomorph merged commit 344dd2e into master Nov 4, 2023
2 checks passed
@noomorph noomorph deleted the feat/improved-global branch November 4, 2023 12:36
Copy link

github-actions bot commented Nov 4, 2023

🎉 This PR is included in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant