Closed AlexB52 closed 4 months ago
@AlexB52 I'm concerned that log warnings will almost never be seen. That's why Kernel.warn
or Kernel#warn
was being called--so that these warnings would be visible. But clearly there are cases where people don't want to see one or more of the warnings.
I wonder if instead the warnings could be configurable in listen
? Maybe there could be a proc that could be registered that would get to look at each warning and decide whether to show it or not?
@ColinDKelley Not sure I understand the registration proc. Is your idea of a proc like this? What is the preferred way to make this globally available? Can you provide some pseudocode to illustrate the idea please?
warn = ->(message) {
return if ENV['LISTEN_GEM_DISABLE_WARNING'].present?
Kernel.warn(message)
}
What about a Listen::Warning class that calls Kernel.warn
unless a ENV variable LISTEN_GEM_DISABLE_WARNING
is set. That would make it a bit more explicit maybe?
Something like:
module Listen
class Warning
module_function
def warn(message)
return if ENV['LISTEN_GEM_DISABLE_WARNING'].present?
Kernel.warn(message)
end
end
end
Fix #572
In case we can move these calls to Listen.logger here is the PR for the change.