-
Notifications
You must be signed in to change notification settings - Fork 582
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
Allow Log to print undef values #2091
base: main
Are you sure you want to change the base?
Conversation
Fix issue where providing undef value to be logged results in an error.
What's the use case for this? And how much of a performance regression does it cause? |
In my experience, causing an error when an
I haven't found any performance tests in the suite. Both |
I don't think it's worth it. Doesn't seem to difficult to avoid it on the way in. |
@jhthorsen every caller could |
I'm not sure how often you really need that though. I made https://metacpan.org/pod/Mojolicious::Plugin::Logf for this reason (and some others), but I don't use it that often in my own projects, since it's often overkill imo. |
Definitely. However with Additionally a useful |
In adition to the comments by guest20 (which I fully agree with), current implementation of Log does not even allow for clean subclassing to override the behavior in an app. Writing an additional if statement every time I want to log some value across an entire application, while not "difficult" is still quite cumbersome and makes for poor code readability. I was not aware of Logf, so thanks for the tip. In case this PR is not approved, I'll use iot instead of patching Log in my CI pipeline (which is what I do right now). |
Print "undef" when an undef value is provided to Log, instead of throwing an error.