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

Multistream doesn't work with custom levels #1518

Closed
wallactp opened this issue Aug 12, 2022 · 5 comments
Closed

Multistream doesn't work with custom levels #1518

wallactp opened this issue Aug 12, 2022 · 5 comments

Comments

@wallactp
Copy link

I have a need for custom levels to meet my logging requirements. I'm also using multi-stream to stream to multiple/different destinations based on log level. Multistream doesn't allow me to use a custom level to restrict logging.

A simplified version of my setup below. I'd like to be able to use my custom level in the StreamEntry.level property.

// custom log levels
const  customLevels = { 
  crit:  60,
  error: 50,
  warn:  40,
  audit: 30, // custom
  info:  20,
  debug: 10,
};

// Stream definition
const streamEntry: StreamEntry = {
  level: 'audit', // I can't use the string or number for my custom level here because it must be of type Level
  stream: consoleTransport
};

// Logger definition
export const logger = pino(
  {
    level: 'debug',
    customLevels,
    useOnlyCustomLevels: true,
  },
  pino.multistream([streamEntry], { levels: customLevels })
);
@mcollina
Copy link
Member

I don't think it would work.

@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@wallactp
Copy link
Author

I believe this was fixed by #1760

@mcollina
Copy link
Member

thx

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants