You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Log nicely forces you to encapsulate logging-specific logic into blocks which aren't executed unless the log level is going to print something.
Is your feature request related to a problem? Please describe clearly and concisely what is it.
The other day I found myself doing this to avoid a blank line being emitted to the log:
defget_things_and_filter
list_of_things = whatever_list_generator
filtered_list = filter_method list_of_things
if filtered_list.size < list_of_things.size # comparison doesn't need to run when log level isn't <= debugLog.for("get_things_and_filter").debug { "filter_method removed #{filtered_list.size - list_of_things.size} things from the list!" }
endend
Describe the feature you would like, optionally illustrated by examples, and how it will solve the above problem.
Does it make sense to modify the API so that this wouldn't print a blank line in the log?
defget_things_and_filter
list_of_things = whatever_list_generator
filtered_list = filter_method list_of_things
Log.for("get_things_and_filter").debug doif filtered_list.size < list_of_things.size # comparison doesn't run when log level isn't <= debug"filter_method removed #{filtered_list.size - list_of_things.size} things from the list!"endendend
Describe considered alternative solutions, and the reasons why you have not proposed them as a solution here.
Other options include some sort of magic flag or exception. I don't like that.
Does it break backward compatibility, if yes then what's the migration path?
I suppose technically yes. Code which is written to emit a blank line would no longer emit the blank line.
The text was updated successfully, but these errors were encountered:
I think it would be a good change to not emit a log entry when the block returns nil. An entry with nil message does't make much sense. If you want an entry without a message, you can use the empty string for that (that's what the nil gets turned to anyway).
Feature Request
Log
nicely forces you to encapsulate logging-specific logic into blocks which aren't executed unless the log level is going to print something.The other day I found myself doing this to avoid a blank line being emitted to the log:
Does it make sense to modify the API so that this wouldn't print a blank line in the log?
Other options include some sort of magic flag or exception. I don't like that.
I suppose technically yes. Code which is written to emit a blank line would no longer emit the blank line.
The text was updated successfully, but these errors were encountered: