Bugzilla – Attachment 18874 Details for
Bug 8190
Add a logging module to Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8190: QA Followup
Bug-8190-QA-Followup.patch (text/plain), 5.67 KB, created by
Marcel de Rooy
on 2013-06-12 11:44:24 UTC
(
hide
)
Description:
Bug 8190: QA Followup
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-06-12 11:44:24 UTC
Size:
5.67 KB
patch
obsolete
>From 2426928d1422ba0c611b4f757297fca2afb74cc5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 3 Jan 2013 12:45:38 +0100 >Subject: [PATCH] Bug 8190: QA Followup >Content-Type: text/plain; charset=utf-8 > >- Remove the private variables >- Remove the use of C4::Context in the UT >- Remove the Exporter > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Context.pm | 1 - > Koha/Utils/Logger.pm | 56 ++++++++++++++++--------------------------------- > opac/opac-search.pl | 4 +- > t/Logger.t | 9 +------ > 4 files changed, 22 insertions(+), 48 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 1af0ca5..d8712be 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -1244,7 +1244,6 @@ this method creates one, and caches it. > sub logger > { > my $self = shift; >- my $sth; > > if ( defined( $context->{"logger"} ) ) { > return $context->{"logger"}; >diff --git a/Koha/Utils/Logger.pm b/Koha/Utils/Logger.pm >index e8c0b91..c7b4680 100644 >--- a/Koha/Utils/Logger.pm >+++ b/Koha/Utils/Logger.pm >@@ -3,44 +3,15 @@ package Koha::Utils::Logger; > use Modern::Perl; > use Log::LogLite; > >-use base 'Exporter'; >-our @EXPORT_OK = qw($log); >- >-my $UNUSABLE_LOG_LEVEL = 1; >-my $CRITICAL_LOG_LEVEL = 2; >-my $ERROR_LOG_LEVEL = 3; >-my $WARNING_LOG_LEVEL = 4; >-my $NORMAL_LOG_LEVEL = 5; >-my $INFO_LOG_LEVEL = 6; >-my $DEBUG_LOG_LEVEL = 7; >- >-my $LEVEL_STR = { >- $UNUSABLE_LOG_LEVEL => 'UNUS ', >- $CRITICAL_LOG_LEVEL => 'CRIT ', >- $ERROR_LOG_LEVEL => 'ERROR ', >- $WARNING_LOG_LEVEL => 'WARN ', >- $NORMAL_LOG_LEVEL => 'NORMAL', >- $INFO_LOG_LEVEL => 'INFO ', >- $DEBUG_LOG_LEVEL => 'DEBUG ', >-}; >- > use Data::Dumper; > >-our $log = undef; >- > sub new { > my ( $proto, $params ) = @_; >- >- return $log >- if $log >- and ( not defined $params->{file} >- or not defined $log->{FILE_PATH} >- or $params->{file} eq $log->{FILE_PATH} ); > my $class = ref($proto) || $proto; > my $self = {}; > my $LOG_PATH = defined $ENV{KOHA_LOG} ? $ENV{KOHA_LOG} : undef; > $self->{FILE_PATH} = defined $params->{file} ? $params->{file} : $LOG_PATH; >- $self->{LEVEL} = defined $params->{level} ? $params->{level} : $INFO_LOG_LEVEL; >+ $self->{LEVEL} = defined $params->{level} ? $params->{level} : 5; > $self->{LOGGED_MESSAGES} = []; > > if ( not defined $self->{FILE_PATH} ) { >@@ -54,6 +25,15 @@ sub new { > sub _write { > my ( $self, $msg, $log_level, $dump, $cb ) = @_; > >+ my $LEVEL_STR = { >+ 1 => 'UNUS ', >+ 2 => 'CRIT ', >+ 3 => 'ERROR ', >+ 4 => 'WARN ', >+ 5 => 'NORMAL', >+ 6 => 'INFO ', >+ 7 => 'DEBUG ', >+ }; > if ( not $self->{LOGGER} ) { > if ( $log_level <= $self->{LEVEL} ) { > print STDERR "[" . localtime() . "] " . "$LEVEL_STR->{$log_level}: " . $msg . ( $cb ? " (" . $cb . ")" : "" ) . "\n"; >@@ -76,45 +56,45 @@ sub _write { > sub unusable { > my ( $self, $msg, $dump ) = @_; > my $cb = $self->_called_by(); >- $self->_write( $msg, $UNUSABLE_LOG_LEVEL, $dump, $cb ); >+ $self->_write( $msg, 1, $dump, $cb ); > } > > sub critical { > my ( $self, $msg, $dump ) = @_; > my $cb = $self->_called_by(); >- $self->_write( $msg, $CRITICAL_LOG_LEVEL, $dump, $cb ); >+ $self->_write( $msg, 2, $dump, $cb ); > } > > sub error { > my ( $self, $msg, $dump ) = @_; > my $cb = $self->_called_by(); >- $self->_write( $msg, $ERROR_LOG_LEVEL, $dump, $cb ); >+ $self->_write( $msg, 3, $dump, $cb ); > } > > sub warning { > my ( $self, $msg, $dump ) = @_; > my $cb = $self->_called_by(); >- $self->_write( $msg, $WARNING_LOG_LEVEL, $dump, $cb ); >+ $self->_write( $msg, 4, $dump, $cb ); > } > > sub log { > my ( $self, $msg, $dump ) = @_; >- $self->_write( $msg, $NORMAL_LOG_LEVEL, $dump ); >+ $self->_write( $msg, 5, $dump ); > } > > sub normal { > my ( $self, $msg, $dump ) = @_; >- $self->_write( $msg, $NORMAL_LOG_LEVEL, $dump ); >+ $self->_write( $msg, 5, $dump ); > } > > sub info { > my ( $self, $msg, $dump ) = @_; >- $self->_write( $msg, $INFO_LOG_LEVEL, $dump ); >+ $self->_write( $msg, 6, $dump ); > } > > sub debug { > my ( $self, $msg, $dump ) = @_; >- $self->_write( $msg, $DEBUG_LOG_LEVEL, $dump ); >+ $self->_write( $msg, 7, $dump ); > } > > sub level { >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index bfc2177..9046062 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -51,14 +51,14 @@ use C4::Tags qw(get_tags); > use C4::Branch; # GetBranches > use C4::SocialData; > use C4::Ratings; >-use Koha::Utils::Logger qw/$log/; >+use Koha::Utils::Logger; > > use POSIX qw(ceil floor strftime); > use URI::Escape; > use Storable qw(thaw freeze); > use Business::ISBN; > >-$log = Koha::Utils::Logger->new({level => C4::Context->preference("LogLevel")}); >+my $log = Koha::Utils::Logger->new({level => C4::Context->preference("LogLevel")}); > > my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); > # create a new CGI object >diff --git a/t/Logger.t b/t/Logger.t >index 1e42180..6ee3f0b 100644 >--- a/t/Logger.t >+++ b/t/Logger.t >@@ -4,19 +4,14 @@ use utf8; > use Modern::Perl; > > use Test::More; >-require C4::Context; >-import C4::Context; >-plan tests => 15; >+plan tests => 13; > > $ENV{KOHA_LOG} = q{/tmp/logger.log}; > > my $logfile = $ENV{KOHA_LOG}; > > use_ok('Koha::Utils::Logger'); >-isnt(C4::Context->preference("LogLevel"), undef, "Check LogLevel syspref"); >-use Koha::Utils::Logger qw/$log/; >-is($log, undef, "Check \$log is undef"); >-$log = Koha::Utils::Logger->new({level => 3}); >+my $log = Koha::Utils::Logger->new({level => 3}); > isnt($log, undef, "Check \$log is not undef"); > > >-- >1.7.7.6
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 8190
:
9921
|
10996
|
12257
|
12264
|
12265
|
12270
|
12282
|
12283
|
12284
|
12287
|
12743
|
12744
|
12745
|
12746
|
13739
|
13740
|
13762
|
13763
|
13925
|
13926
|
14294
|
14296
|
14318
|
14319
|
14320
|
14321
|
14324
|
14388
|
14703
|
14704
|
14705
|
16426
|
16427
|
16428
|
16429
|
16430
|
18799
|
18800
|
18801
|
18802
|
18803
|
18819
|
18820
|
18870
|
18871
|
18872
|
18873
|
18874
|
18875
|
18876
|
18877
|
18880
|
18881
|
18882
|
18883
|
18884
|
18886
|
18887
|
18888
|
18890
|
34837
|
34838
|
34839
|
34840
|
34841
|
34842
|
34843
|
34844
|
34845