houseabsolute / Log-Dispatch

Dispatches messages to one or more outputs
https://metacpan.org/release/Log-Dispatch/
Other
12 stars 29 forks source link

Please add fatal #44

Open nigelhorne opened 7 years ago

nigelhorne commented 7 years ago

Please add a 'fatal' method which should be the same as 'critical'. This would add compatibility with Log::Log4perl.

nigelhorne commented 7 years ago

Also, would you please add 'warn' as well as 'warning'?

preaction commented 7 years ago

The docs say that "We also allow 'warn' as a synonym for 'warning'" already, so if it's not working, that's a bug. As for compatibility with other logging systems, isn't that what Log::Any is for? If it's still desirable to put it in Log-Dispatch, then it'd probably be good to do the same mapping as it does (which is, yes, fatal => 'critical').

autarch commented 7 years ago

I think I agree with preaction that if you need compatibility between logging systems then Log::Any is the way to go.

nigelhorne commented 7 years ago

This is for Log::WarnDie, so I don't see how that would help.

preaction commented 7 years ago

The Log::WarnDie docs say "Any object that provides a warning, error and critical method, will operate with this module." This makes me think Log::WarnDie would already work with Log::Any::Adapter objects, which should all implement those three methods[1]. So you could use the existing Log::Any::Adapter::Dispatch module (which connects Log::Any and Log::Dispatch), and the corresponding Log::Any::Adapter::Log4perl adapter (the Log::WarnDie docs mention that Log4perl does not support critical, but Log::Any::Adapter::Log4perl does and maps it to fatal).

I think Log::Any is a better solution for Log::WarnDie: If you want to log to files or syslog or Mojolicious or other facilities, you don't need to take the middle step of using Log::Dispatch and setting up its output handles. You just directly configure the output adapters on the Log::WarnDie object.

If all else fails, a quick can() check on the Log::Dispatch/Log::Log4perl object would see which methods you have available to you so you can pick which of critical or fatal to use (unless you're planning on using both for different things, at which point I'd go with Log::Any).

[1]: People have been giving me maintainership of adapters left and right, so if any don't work with Log::WarnDie, I probably have the permissions needed to fix them.