Replies: 8 comments 6 replies
-
I didn't think about it yet. type AbstractLogger = Record<
"info" | "warn" | "debug" | "error",
(message: string, meta?: any) => any
> However, it might be a breaking change to the I need to think on it. Thanks for idea, @bobgubko |
Beta Was this translation helpful? Give feedback.
-
I think I found a way, @bobgubko Let me know what you think |
Beta Was this translation helpful? Give feedback.
-
That looks good to me overall. I'm not sure whether logger arguments should be limited to One more question regarding the logger. Is it possible in existing implementation to use |
Beta Was this translation helpful? Give feedback.
-
The narrow type of the arguments Check out this example, @bobgubko : ![]() I use the loose type you mentioned and assign it to in config — and it works. |
Beta Was this translation helpful? Give feedback.
-
As long as your implementation is aware of the actual logger you can use every feature that this logger provides. I didn't make the same for the handlers of Will that work for you, @bobgubko ? |
Beta Was this translation helpful? Give feedback.
-
That's not what I meant about the |
Beta Was this translation helpful? Give feedback.
-
Dear @bobgubko , I'd like to inform you that after a series of some serious considerations and revisions of the general concept, For that purpose I'm going to offer module augmentation technique, which, however, turned out to be very robust and for your case will work even better. Here is an example: import pino, { Logger } from "pino";
import { createConfig } from "express-zod-api";
const logger = pino({
transport: {
target: "pino-pretty",
options: { colorize: true },
},
});
const config = createConfig({ logger });
// Setting the type of logger used
declare module "express-zod-api" {
interface LoggerOverrides extends Logger {}
} When you set the All that I'm going to introduce in v15 in december. |
Beta Was this translation helpful? Give feedback.
-
@bobgubko , I'm glad to inform you that the feature is now available for you in recently released version 15. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way or whether you planning to add support for using other logger library than winston? First thing I learned about winston is their core issues which are pinned in their issues. Also initially I used pino logger but had to switch to winston because I haven't found a way to make it work with express-zod-api.
Beta Was this translation helpful? Give feedback.
All reactions