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

Built-in logger class with .child() method #1778

Merged
merged 25 commits into from
May 23, 2024
Merged

Conversation

RobinTail
Copy link
Owner

@RobinTail RobinTail commented May 18, 2024

Can do this now (without additional libraries):

import { randomUUID } from "node:crypto";
import { BuiltinLogger, createConfig } from "express-zod-api";

declare module "express-zod-api" {
  interface LoggerOverrides extends BuiltinLogger {}
}

const config = createConfig({
  logger: { level: "debug", color: true },
  childLoggerProvider: ({ parent }) =>
    parent.child({ requestId: randomUUID() }), // context
});

requestId is special and displayed after the timestamp, looks this way:

image

@RobinTail RobinTail added enhancement New feature or request refactoring The better way to achieve the same result labels May 18, 2024
Copy link

coveralls-official bot commented May 18, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 7deff30 on builtin-logger-class
into ecda874 on master.

@RobinTail RobinTail changed the title Built-in logger class with a .child() method Built-in logger class with .child() method May 18, 2024
@RobinTail RobinTail marked this pull request as ready for review May 22, 2024 21:40
Copy link
Owner Author

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready

@RobinTail RobinTail merged commit aabef58 into master May 23, 2024
11 checks passed
@RobinTail RobinTail deleted the builtin-logger-class branch May 23, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring The better way to achieve the same result
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant