--- trunk/lib/WebPAC/Common.pm 2005/07/17 11:37:07 16 +++ trunk/lib/WebPAC/Common.pm 2005/07/24 11:17:44 29 @@ -6,6 +6,9 @@ use Log::Log4perl qw/get_logger :levels/; use Time::HiRes qw/time/; +# If ture, enable logging debug +my $log_debug = 0; + =head1 NAME WebPAC::Common - internal methods called from other WebPAC modules @@ -139,12 +142,19 @@ will be created. If any mode which inherits from this one is called with C flag, it will turn logging to debug level. +This function will also read C value from current object and try +to read that as configuration file if it exists. + =cut sub _init_logger { my $self = shift; my $file = shift; + $file ||= $self->{'log_conf'}; + $file = 'conf/log.conf'; + my $name = (caller(2))[3] || caller; if ($file) { + warn "# $name is using $file logger\n" if ($log_debug); Log::Log4perl->init($file); } else { my $conf = q( ); @@ -160,6 +170,9 @@ log4perl.appender.SCREEN.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n _log4perl_ + warn "# $name is using debug logger\n" if ($log_debug); + } else { + warn "# $name is using null logger\n" if ($log_debug); } Log::Log4perl->init( \$conf ); } @@ -178,9 +191,11 @@ sub _get_logger { my $self = shift; - $self->{'_logger_ok'} ||= $self->_init_logger; + my $name = (caller(2))[3] || caller; + $self->{'_logger_'} ||= $self->_init_logger; + + warn "# get_logger( $name )\n" if ($log_debug); - my $name = (caller(1))[3] || caller; return get_logger($name); }