CGI-Application-Plugin-LogDispatch
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/LogDispatch.pm view on Meta::CPAN
name => 'screen',
stderr => 1,
min_level => 'debug',
);
$options{callbacks} = \&_append_newline if $options->{APPEND_NEWLINE};
$log->add( Log::Dispatch::Screen->new( %options ) );
}
_set_object($frompkg||$self, $log);
# CAP::DevPopup support
if (UNIVERSAL::can($self, 'devpopup')) {
# Register our report with DevPopup
$self->add_callback( 'devpopup_report', \&_devpopup_report );
# Create logger to capture all log entries
my %options = (
'name' => 'DevPopup',
'min_level' => 'debug',
'filename' => File::Spec->devnull(),
'callbacks' => sub {
my %args = @_;
push( @{$self->{LOG_DISPATCH_DEVPOPUP_HISTORY}}, [$args{level}, $args{message}] );
},
lib/CGI/Application/Plugin/LogDispatch.pm view on Meta::CPAN
# object or a set of configuration parameters
require Class::ISA;
foreach my $super ($class, Class::ISA::super_path($class)) {
no strict 'refs';
return (${$super.'::__LOG_OBJECT'}, undef) if ${$super.'::__LOG_OBJECT'};
return (undef, ${$super.'::__LOG_CONFIG'}, $super) if ${$super.'::__LOG_CONFIG'};
}
return;
}
sub _devpopup_report {
my $self = shift;
my $r=0;
my $history = join $/, map {
$r=1-$r;
qq(<tr class="@{[$r?'odd':'even']}"><td valign="top">$_->[0]</td><td>$_->[1]</td></tr>)
}
@{$self->{LOG_DISPATCH_DEVPOPUP_HISTORY}};
$self->devpopup->add_report(
title => 'Log Entries',
summary => 'All entries logged via Log::Dispatch',
report => qq(
<style type="text/css">
tr.even{background-color:#eee}
</style>
<div style="font-size: 80%">
<table>
<thead><tr><th>Level</th><th>Message</th></tr></thead>
<tbody>$history</tbody>
lib/CGI/Application/Plugin/LogDispatch.pm view on Meta::CPAN
}
=head1 DESCRIPTION
CGI::Application::Plugin::LogDispatch adds logging support to your L<CGI::Application>
modules by providing a L<Log::Dispatch> dispatcher object that is accessible from
anywhere in the application.
If you have L<CGI::Application::Plugin::DevPopup> installed, a "Log Entries"
report is added to the popup window, containing all of the entries that were
logged during the execution of the runmode.
=head1 METHODS
=head2 log
This method will return the current L<Log::Dispatch> dispatcher object. The L<Log::Dispatch>
object is created on the first call to this method, and any subsequent calls will return the
same object. This effectively creates a singleton log dispatcher for the duration of the request.
If C<log_config> has not been called before the first call to C<log>, then it will choose some
( run in 1.814 second using v1.01-cache-2.11-cpan-364913b4093 )