[Koha-bugs] [Bug 8190] Add a logging module to Koha, that can report log message to staff interface (for developer use)
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Sat Dec 29 08:15:45 CET 2012
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8190
Chris Cormack <chris at bigballofwax.co.nz> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |In Discussion
--- Comment #58 from Chris Cormack <chris at bigballofwax.co.nz> ---
If we are going to always access the logger object via C4::Context, we could do
this all without the need of a new module.
if in C4::Context we added something very similar to
use Log::Log4perl qw(:levels get_logger);
my $layout_class = "Log::Log4perl::Layout::PatternLayout";
my $layout_pattern = "[%d] %p - %M - %m - %T%n";
my $config = <<"END";
log4perl.logger = INFO, Logfile, Screen
log4perl.appender.Logfile = Log::Log4perl::Appender::File
log4perl.appender.Logfile.filename = $ENV{KOHA_LOG}
log4perl.appender.Logfile.mode=append
log4perl.appender.Logfile.layout = $layout_class
log4perl.appender.Logfile.layout.ConversionPattern=$layout_pattern
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.layout = $layout_class
log4perl.appender.Screen.layout.ConversionPattern = $layout_pattern
END
Log::Log4perl->init( \$config );
and then in there a sub
sub logger
{
my $self = shift;
if ( defined( $context->{"logger"} ) ) {
return $context->{"logger"};
}
$context->{"logger"} = Log::Log4perl->get_logger('C4::Context');
$context->{"logger"}->level(C4::Context->preference("LogLevel"));
return $context->{"logger"};
}
We would have a logger logging to stderr and to the file defined. We would need
to change our numeric loglevels to strings, like FATAL, WARN etc but that is
easily done. And if we did want our 2 extra ones, we can add these 2 lines
# set up our custom log leves CRIT and NORMAL
Log::Log4perl::Logger::create_custom_level( 'CRIT', 'FATAL');
Log::Log4perl::Logger::create_custom_level( 'NORMAL', 'WARN' );
Before we do the init.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list