Changeset 1078

Show
Ignore:
Timestamp:
07/13/06 16:03:26
Author:
miyagawa
Message:

use Term::Encoding to detect log encoding automatically. Fixes #329

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/Makefile.PL

    r1064 r1078  
    2828requires('XML::LibXML'); 
    2929requires('XML::Atom', 0.19); 
    30 requires('XML::RSS::LibXML', 0.20), 
     30requires('XML::RSS::LibXML', 0.20); 
     31requires('Term::Encoding'); 
    3132 
    3233build_requires(Test::More => 0.42); 
  • trunk/plagger/lib/Plagger.pm

    r1076 r1078  
    66use Carp; 
    77use Data::Dumper; 
     8use Encode; 
    89use File::Copy; 
    910use File::Basename; 
     
    5455    $self->{conf} = $config->{global}; 
    5556    $self->{conf}->{log} ||= { level => 'debug' }; 
     57 
     58    if (eval { require Term::Encoding }) { 
     59        $self->{conf}->{log}->{encoding} ||= Term::Encoding::get_encoding; 
     60    } 
    5661 
    5762    no warnings 'redefine'; 
     
    367372    } 
    368373 
    369     chomp($msg); 
    370374    if ($self->should_log($level)) { 
     375        chomp($msg); 
     376        if ($self->{log}->{encoding}) { 
     377            $msg = Encode::encode($self->{log}->{encoding}, $msg); 
     378        } 
    371379        warn "$caller [$level] $msg\n"; 
    372380    }