learnedbyerror has asked for the wisdom of the Perl Monks concerning the following question:
Hello Oh Wise Monks
The village idiot returns with another request for your guidance. I have long been a devotee of the most excellent Log::Log4perl. However, I am currently working on a module that I think may benefit others and will place it on CPAN. As such, I plan to change the log producer to Log::Any. For most of my logging calls, this is a trivial change. There are several cases where the change is not so trivial. They are replacing $logger->logdie (which I shouldn't be using in a module anyway ) and more importantly the Log4perl levels that handle Carp: $logger->log(carp|cluck|croak|confess).
My question is, "what are your recommended means of integrating Log::Any where die and Carp functionalities are needed?"
Some of the options are not too disruptive, replace $logger->logdie(...)with $logger->logcritical(...) && die(...)
Whereas cluck or confess would be something more like
$logger->critical(...); my $long_message = Carp::longmess; foreach my $line ( $long_message =~ m/^.+$/msg ) { $logger->critical( $line ); } confess(...)
NOTE: untested code example, intended for representative use only
While functional, it seems inelegant to have to add these boilerplate lines or add a subroutine or class method to handle this. Are their more elegant ways of handling this need with Log::Any?
Thanks in advance for your sage advice!
lbe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Log::Any with die and carp
by 1nickt (Canon) on Dec 17, 2018 at 01:11 UTC | |
by learnedbyerror (Monk) on Dec 17, 2018 at 13:44 UTC | |
|
Re: Log::Any with die and carp
by karlgoethebier (Abbot) on Dec 17, 2018 at 13:16 UTC | |
by learnedbyerror (Monk) on Dec 17, 2018 at 13:45 UTC | |
by Laurent_R (Canon) on Dec 17, 2018 at 19:00 UTC | |
|
Re: Log::Any with die and carp
by perlancar (Hermit) on Dec 19, 2018 at 11:16 UTC | |
by learnedbyerror (Monk) on Dec 19, 2018 at 14:37 UTC | |
by perlancar (Hermit) on Dec 20, 2018 at 10:24 UTC | |
by hippo (Archbishop) on Dec 20, 2018 at 12:01 UTC | |
by perlancar (Hermit) on Dec 20, 2018 at 12:21 UTC |