/[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 9 by dpavlin, Sat Jul 16 17:14:43 2005 UTC revision 13 by dpavlin, Sat Jul 16 23:56:14 2005 UTC
# Line 269  sub _eval { Line 269  sub _eval {
269          return $ret || undef;          return $ret || undef;
270  }  }
271    
 =head2 _sort_by_order  
   
 Sort xml tags data structure accoding to C<order=""> attribute.  
   
 =cut  
   
 sub _sort_by_order {  
         my $self = shift;  
   
         my $va = $self->{'import_xml'}->{'indexer'}->{$a}->{'order'} ||  
                 $self->{'import_xml'}->{'indexer'}->{$a};  
         my $vb = $self->{'import_xml'}->{'indexer'}->{$b}->{'order'} ||  
                 $self->{'import_xml'}->{'indexer'}->{$b};  
   
         return $va <=> $vb;  
 }  
   
 =head2 _x  
   
 Convert string from UTF-8 to code page defined in C<import_xml>.  
   
  my $text = $webpac->_x('utf8 text');  
   
 Default application code page is C<ISO-8859-2>. You will probably want to  
 change that when creating new instance of object based on this one.  
   
 =cut  
   
 sub _x {  
         my $self = shift;  
         my $utf8 = shift || return;  
   
         # create UTF-8 convertor for import_xml files  
         $self->{'utf2cp'} ||= Text::Iconv->new('UTF-8' ,$self->{'code_page'} || 'ISO-8859-2');  
   
         return $self->{'utf2cp'}->convert($utf8) ||  
                 $self->_get_logger()->logwarn("can't convert '$utf8'");  
 }  
   
272  =head2 _init_logger  =head2 _init_logger
273    
274  This function will init C<Log::Log4perl> using provided configuration file.  This function will init C<Log::Log4perl> using provided configuration file.
# Line 315  This function will init C<Log::Log4perl> Line 276  This function will init C<Log::Log4perl>
276    $webpac->_init_logger('/path/to/log.conf');    $webpac->_init_logger('/path/to/log.conf');
277    
278  If no path to configuration file is given, dummy empty configuration  If no path to configuration file is given, dummy empty configuration
279  will be create.  will be created. If any mode which inherits from this one is called
280    with C<debug> flag, it will turn logging to debug level.
281    
282  =cut  =cut
283    
# Line 326  sub _init_logger { Line 288  sub _init_logger {
288                  Log::Log4perl->init($file);                  Log::Log4perl->init($file);
289          } else {          } else {
290                  my $conf = q( );                  my $conf = q( );
291                    if ($self->{'debug'}) {
292                            $conf = << '_log4perl_';
293    
294    log4perl.rootLogger=INFO, SCREEN
295    
296    log4perl.logger.WebPAC.=DEBUG
297    
298    log4perl.appender.SCREEN=Log::Log4perl::Appender::Screen
299    log4perl.appender.SCREEN.layout=PatternLayout
300    log4perl.appender.SCREEN.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n
301    
302    _log4perl_
303                    }
304                  Log::Log4perl->init( \$conf );                  Log::Log4perl->init( \$conf );
305          }          }
306  }  }

Legend:
Removed from v.9  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26