sedusedan has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
I need to temporarily log to an additional Log::Any adapter. Here's an example using Log::Any::Adapter::Callback:
# app.pl use Log::Any '$log'; use Log::Any::Adapter; Log::Any::Adapter->set('Log4perl', some=>'param', ...); # ... if ($some_debugging_flag) { # additionally log to a remote socket Log::Any::Adapter->set( {lexically => \my $lex}, 'CallBack', logging_cb => sub { my ($method, $self, $format, @params) = @_; $socket->print($format, "\r\n"); } ); some_func_which_logs(); } else { # no additional adapter some_func_which_logs(); } # back to normal, logging to Log4perl only ...
What would be the proper way to access the previous adapter inside the logging_cb callback so we can invoke the previous adapter's logging $method too to pass the log message to it? In other words, if $some_debugging_flag is set, during some_func_which_logs() I'd like to log to Log4perl (or whatever the previous adapter is) *and* to a remote socket as well.
Any input appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Log::Any: logging to additional adapter
by swartz (Beadle) on May 16, 2011 at 14:07 UTC | |
by sedusedan (Pilgrim) on May 16, 2011 at 17:34 UTC |