Bugzilla – Attachment 38980 Details for
Bug 14167
Add Koha::Logger based on Log4perl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14167 - Add Koha::Logger based on Log4perl
Bug-14167---Add-KohaLogger-based-on-Log4perl.patch (text/plain), 6.51 KB, created by
Kyle M Hall (khall)
on 2015-05-08 13:52:32 UTC
(
hide
)
Description:
Bug 14167 - Add Koha::Logger based on Log4perl
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-05-08 13:52:32 UTC
Size:
6.51 KB
patch
obsolete
>From 89a2edbb2dbec9c1b0fa9964a2a465b938f4f862 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 7 May 2015 11:20:50 -0400 >Subject: [PATCH] Bug 14167 - Add Koha::Logger based on Log4perl > >Koha needs a better logger, and it seems like the best solution would be >to take advantage of Log4perl which is already a fully featured logger. >We use Log4perl to selectively decide what statements should be logged, >and where they should go! > >Test plan: >0) Install Log::Log4perl via packages or cpan >1) Apply this patch >2) Copy etc/log4perl.conf to your koha conf directory, edit the paths > to match your current error logs >3) Edit your koha-conf file and add the > <log4perl_conf>/path/to/log4perl.conf</log4perl_conf> line >4) Watch your intranet and opac error logs >5) Perform a renewal via the staff interface, note there is nothing new > in the log file >7) Update the log4perl.conf, change the log level from DEBUG to TRACE > for both the staff and opac sides >8) Perform a renewal via the staff interface, note the logged lines >9) Perform a renewal via the opac, note the logged lines >--- > C4/Circulation.pm | 8 ++++- > C4/Installer/PerlDependencies.pm | 5 +++ > Koha/Logger.pm | 75 ++++++++++++++++++++++++++++++++++++++ > etc/koha-conf.xml | 1 + > etc/log4perl.conf | 13 +++++++ > svc/renew | 2 + > 6 files changed, 103 insertions(+), 1 deletions(-) > create mode 100644 Koha/Logger.pm > create mode 100644 etc/log4perl.conf > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f991680..8edc4f9 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -50,6 +50,7 @@ use Koha::DateUtils; > use Koha::Calendar; > use Koha::Borrower::Debarments; > use Koha::Database; >+use Koha::Logger; > use Carp; > use List::MoreUtils qw( uniq ); > use Date::Calc qw( >@@ -2787,6 +2788,9 @@ sub AddRenewal { > my $datedue = shift; > my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); > >+ my $logger = Koha::Logger->get("C4::Circulation::AddRenewal"); >+ $logger->trace( "PARAMS: " . Dumper( { borrowernumber => $borrowernumber, itemnumber => $itemnumber, branch => $branch, datedue => $datedue, lastreneweddate => $lastreneweddate } ) ); >+ > my $item = GetItem($itemnumber) or return; > my $biblio = GetBiblioFromItemNumber($itemnumber) or return; > >@@ -2892,7 +2896,9 @@ sub AddRenewal { > borrowernumber => $borrowernumber, > ccode => $item->{'ccode'}} > ); >- return $datedue; >+ >+ $logger->trace("RETURNING $datedue"); >+ return $datedue; > } > > sub GetRenewCount { >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 4b2067e..49e3d47 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -732,6 +732,11 @@ our $PERL_DEPS = { > 'required' => '0', > 'min_ver' => '0.31', > }, >+ 'Log::Log4perl' => { >+ 'usage' => 'Core', >+ 'required' => '1', >+ 'min_ver' => '1.29', >+ }, > }; > > 1; >diff --git a/Koha/Logger.pm b/Koha/Logger.pm >new file mode 100644 >index 0000000..8f6ca8f >--- /dev/null >+++ b/Koha/Logger.pm >@@ -0,0 +1,75 @@ >+package Koha::Logger; >+ >+# Copyright 2015 ByWater Solutions >+# kyle@bywatersolutions.com >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+Koha::Log >+ >+=head1 SYNOPSIS >+ >+ use Koha::Log; >+ >+=head1 FUNCTIONS >+ >+=cut >+ >+use Modern::Perl; >+ >+use Log::Log4perl; >+use Carp; >+ >+use C4::Context; >+ >+BEGIN { >+ Log::Log4perl->wrapper_register(__PACKAGE__); >+ >+ my $conf; >+ if ( exists $ENV{"LOG4PERL_CONF"} and $ENV{'LOG4PERL_CONF'} and -s $ENV{"LOG4PERL_CONF"} ) { >+ >+ # Check for web server level configuration first >+ $conf = $ENV{"LOG4PERL_CONF"}; >+ } >+ else { >+ # If no web server level config exists, look in the koha conf file for one >+ $conf = C4::Context->config("log4perl_conf"); >+ } >+ >+ Log::Log4perl->init_once($conf); >+} >+ >+sub get { >+ my ( $class, $category ) = @_; >+ >+ croak("No category passed in!") unless $category; >+ >+ my $interface = C4::Context->interface(); >+ >+ return Log::Log4perl->get_logger("$interface.$category"); >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall, E<lt>kyle@bywatersolutions.comE<gt> >+ >+=cut >+ >+1; >+ >+__END__ >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index 289d51d..cb6ed05 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -114,6 +114,7 @@ __PAZPAR2_TOGGLE_XML_POST__ > <zebra_lockdir>__ZEBRA_LOCK_DIR__</zebra_lockdir> > <use_zebra_facets>1</use_zebra_facets> > <queryparser_config>__KOHA_CONF_DIR__/searchengine/queryparser.yaml</queryparser_config> >+ <log4perl_conf>__KOHA_CONF_DIR__/log4perl.conf</log4perl_conf> > > <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm --> > <ttf> >diff --git a/etc/log4perl.conf b/etc/log4perl.conf >new file mode 100644 >index 0000000..7d6b4e4 >--- /dev/null >+++ b/etc/log4perl.conf >@@ -0,0 +1,13 @@ >+log4perl.logger.intranet = DEBUG, INTRANET >+log4perl.appender.INTRANET=Log::Log4perl::Appender::File >+log4perl.appender.INTRANET.filename=__LOG_DIR__/intranet-error.log >+log4perl.appender.INTRANET.mode=append >+log4perl.appender.INTRANET.layout=PatternLayout >+log4perl.appender.INTRANET.layout.ConversionPattern=[%d] [%p] %m %l %n >+ >+log4perl.logger.opac = DEBUG, OPAC >+log4perl.appender.OPAC=Log::Log4perl::Appender::File >+log4perl.appender.OPAC.filename=__LOG_DIR__/opac-error.log >+log4perl.appender.OPAC.mode=append >+log4perl.appender.OPAC.layout=PatternLayout >+log4perl.appender.OPAC.layout.ConversionPattern=[%d] [%p] %m %l %n >diff --git a/svc/renew b/svc/renew >index fa8475a..7c88f31 100755 >--- a/svc/renew >+++ b/svc/renew >@@ -28,6 +28,8 @@ use C4::Auth qw(check_cookie_auth); > > use Koha::DateUtils qw(output_pref dt_from_string); > >+C4::Context->interface('intranet'); >+ > my $input = new CGI; > > my ( $auth_status, $sessionID ) = >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14167
:
38953
|
38954
|
38980
|
38981
|
38993
|
39103
|
39180
|
39886
|
39887
|
39888
|
39889
|
39890
|
39891
|
39892
|
39893
|
39894
|
39895
|
40200
|
40652
|
40653
|
40657
|
40658
|
40659
|
40660
|
40661
|
40662
|
40663
|
40664
|
41109
|
41111
|
41145
|
41146