/[webpac2]/trunk/lib/WebPAC/Common.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Common.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 28 by dpavlin, Sun Jul 17 11:37:07 2005 UTC revision 29 by dpavlin, Sun Jul 24 11:17:44 2005 UTC
# Line 6  use strict; Line 6  use strict;
6  use Log::Log4perl qw/get_logger :levels/;  use Log::Log4perl qw/get_logger :levels/;
7  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
8    
9    # If ture, enable logging debug
10    my $log_debug = 0;
11    
12  =head1 NAME  =head1 NAME
13    
14  WebPAC::Common - internal methods called from other WebPAC modules  WebPAC::Common - internal methods called from other WebPAC modules
# Line 139  If no path to configuration file is give Line 142  If no path to configuration file is give
142  will be created. If any mode which inherits from this one is called  will be created. If any mode which inherits from this one is called
143  with C<debug> flag, it will turn logging to debug level.  with C<debug> flag, it will turn logging to debug level.
144    
145    This function will also read C<log_conf> value from current object and try
146    to read that as configuration file if it exists.
147    
148  =cut  =cut
149    
150  sub _init_logger {  sub _init_logger {
151          my $self = shift;          my $self = shift;
152          my $file = shift;          my $file = shift;
153            $file ||= $self->{'log_conf'};
154            $file = 'conf/log.conf';
155            my $name = (caller(2))[3] || caller;
156          if ($file) {          if ($file) {
157                    warn "# $name is using $file logger\n" if ($log_debug);
158                  Log::Log4perl->init($file);                  Log::Log4perl->init($file);
159          } else {          } else {
160                  my $conf = q( );                  my $conf = q( );
# Line 160  log4perl.appender.SCREEN.layout=PatternL Line 170  log4perl.appender.SCREEN.layout=PatternL
170  log4perl.appender.SCREEN.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n  log4perl.appender.SCREEN.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n
171    
172  _log4perl_  _log4perl_
173                            warn "# $name is using debug logger\n" if ($log_debug);
174                    } else {
175                            warn "# $name is using null logger\n" if ($log_debug);
176                  }                  }
177                  Log::Log4perl->init( \$conf );                  Log::Log4perl->init( \$conf );
178          }          }
# Line 178  method Line 191  method
191  sub _get_logger {  sub _get_logger {
192          my $self = shift;          my $self = shift;
193    
194          $self->{'_logger_ok'} ||= $self->_init_logger;          my $name = (caller(2))[3] || caller;
195            $self->{'_logger_'} ||= $self->_init_logger;
196    
197            warn "# get_logger( $name )\n" if ($log_debug);
198    
         my $name = (caller(1))[3] || caller;  
199          return get_logger($name);          return get_logger($name);
200  }  }
201    

Legend:
Removed from v.28  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26