alexmarqs / zod-config

Load configuration variables from multiple sources with flexible adapters, ensuring type safety with Zod.
https://www.npmjs.com/package/zod-config
MIT License
34 stars 7 forks source link

custom logger #3

Closed Pfeifenjoy closed 5 months ago

Pfeifenjoy commented 5 months ago

Allow users to pass a custom logging function for warnings.

alexmarqs commented 5 months ago

Thanks for submitting your PR, I will have a look later today! 🙏

alexmarqs commented 5 months ago

Hi @Pfeifenjoy just added small changes to your PR:

Let me know if it fits your purpose and then I can approve and merge it! tks!

Pfeifenjoy commented 5 months ago

Hi @alexmarqs

sounds cool, I am of course good with it. Yeah the build was fucking me up a bit, was not sure if you wanted to stay with pnpm. Actually I tried this out in an application I am building now and noticed that it actually is not the right idea. Usually someone would configure the log level in the config, which is after the adapter is executed.

I am thinking about changing this a bit because my intention was to have the adapters fail silently. That can also be done by leaving the warn log function empty but I am not sure if that is a good approach or if it is better to add the option "silent" to the adapters. Let me know of your opinion.

alexmarqs commented 5 months ago

Hi @Pfeifenjoy , actually why not both 🤔 ? Last night drafted something about your suggestion, see PR changes.(introduced a silentFail for the adapters, maybe we could also have a generic/config level that would apply this setting for all adapters, but I think having it per adapter should be fine for now).

Cheers, let me know your feedback!

alexmarqs commented 5 months ago

I will merge this later today as I think it introduces some small cool features to next release, thanks for the contribution. In the meantime let me know if this fits your use case or if you would like to see any other! If so, feel free to open a new issue or reach me out. Thanks.

alexmarqs commented 5 months ago

Released here. As usual, feel free to share any other suggestions or requests in a new issue. tks!