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
Support passing functions in the default logger implementations #45
Comments
I was just looking for exactly this functionality and I think it would be a nice enhancement. |
@mercutiodesign for now your best bet would be to implement your own printer by copying/pasting the closest one to what you need. Can check if the message is a function and evaluate it before you print. |
I rather like the idea! Since the |
Hi, needed exactly the same but saw that there is no PR for this, so I just did it. |
Closed since #105 is merged. |
Some of our logger statements involve expensive computations like formatting objects to make the logs easy to read. To work around this, we are passing functions for the expensive log statements and they are getting evaluated in the printer right before they need to be printed.
For example:
summarizeGqlPayload
in this case is relatively expensive and something we wouldn't want to be execute in production. Or at least all these little things add up to increased CPU usage. Hence we are passing a function.Our corresponding
stringify
in our custom logger looks something like this to handle functions.Is this worth having as a default for the logger?
The text was updated successfully, but these errors were encountered: