FAQ
I'm printing like this:

  my $octets = 'Быстрая коричневая лиса चाँद पर';
  $r->log->warn( $octets );
  $r->log->warn( Encode::decode_utf8( $octets ) );
print STDERR $octets;


But what I get in the logs is this:

[Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
\xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
\xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
\xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
\xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
[Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
\xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
\xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
\xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
\xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
Быстрая коричневая лиса चाँद पर


So you see (if your mail client allows) bypassing $r->log and printing
directly to STDERR works as I'd like. But I'd like to use $r->log for
logging.

Is this mod_perl doing the mapping?


Here's full output and the httpd.conf to reproduce:

$ httpd -d $(pwd) -f httpd_perl_sections.conf -k start; tail -f error.log

[Tue Sep 23 09:11:56 2014] [notice] Apache/2.2.15 (Unix) mod_perl/2.0.7
Perl/v5.14.2 configured -- resuming normal operations
Hey we are here
[Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82] this is a warning
[Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
\xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
\xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
\xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
\xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
[Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
\xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
\xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
\xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
\xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
Быстрая коричневая лиса चाँद पर


$ cat httpd_perl_sections.conf

LoadModule perl_module
/home/bill/perl5/perlbrew/perls/perl-5.14.2/usr/lib64/httpd/modules/mod_perl.so
LoadModule mime_module modules/mod_mime.so

ErrorLog error.log
TypesConfig /etc/mime.types
PidFile apache.pid


<Perl>
     {
         package Foo;
         use strict;
         use warnings;
         use Apache2::RequestRec;
         use Apache2::RequestIO;
         use Encode;

         my $octets = 'Быстрая коричневая лиса चाँद पर';

         sub handler {
             my $r = shift;
             print STDERR "Hey we are here\n";
             $r->log->warn( 'this is a warning' );

             $r->log->warn( $octets );
             $r->log->warn( Encode::decode_utf8( $octets ) );

             print STDERR $octets;

             $r->content_type('text/plain');
             $r->print( "hello world\n" );

             return Apache2::Const::OK();
         }
     }
</Perl>

Listen 9090
<Directory />
     SetHandler modperl
     PerlResponseHandler Foo
</Directory>



--
Bill Moseley
moseley@hank.org

Search Discussions

  • André Warnier at Sep 23, 2014 at 6:11 pm

    Bill Moseley wrote:
    I'm printing like this:

    my $octets = 'Быстрая коричневая лиса चाँद पर';
    $r->log->warn( $octets );
    $r->log->warn( Encode::decode_utf8( $octets ) );
    print STDERR $octets;


    But what I get in the logs is this:

    [Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
    \xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
    \xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
    \xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
    \xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
    [Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
    \xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
    \xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
    \xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
    \xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
    Быстрая коричневая лиса चाँद पर


    So you see (if your mail client allows) bypassing $r->log and printing
    directly to STDERR works as I'd like. But I'd like to use $r->log for
    logging.

    Is this mod_perl doing the mapping?


    Here's full output and the httpd.conf to reproduce:

    $ httpd -d $(pwd) -f httpd_perl_sections.conf -k start; tail -f error.log

    [Tue Sep 23 09:11:56 2014] [notice] Apache/2.2.15 (Unix) mod_perl/2.0.7
    Perl/v5.14.2 configured -- resuming normal operations
    Hey we are here
    [Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82] this is a warning
    [Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
    \xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
    \xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
    \xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
    \xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
    [Tue Sep 23 09:12:07 2014] [warn] [client 10.5.24.82]
    \xd0\x91\xd1\x8b\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x8f
    \xd0\xba\xd0\xbe\xd1\x80\xd0\xb8\xd1\x87\xd0\xbd\xd0\xb5\xd0\xb2\xd0\xb0\xd1\x8f
    \xd0\xbb\xd0\xb8\xd1\x81\xd0\xb0
    \xe0\xa4\x9a\xe0\xa4\xbe\xe0\xa4\x81\xe0\xa4\xa6 \xe0\xa4\xaa\xe0\xa4\xb0
    Быстрая коричневая лиса चाँद पर


    $ cat httpd_perl_sections.conf

    LoadModule perl_module
    /home/bill/perl5/perlbrew/perls/perl-5.14.2/usr/lib64/httpd/modules/mod_perl.so
    LoadModule mime_module modules/mod_mime.so

    ErrorLog error.log
    TypesConfig /etc/mime.types
    PidFile apache.pid


    <Perl>
    {
    package Foo;
    use strict;
    use warnings;
    use Apache2::RequestRec;
    use Apache2::RequestIO;
    use Encode;

    my $octets = 'Быстрая коричневая лиса चाँद पर';

    sub handler {
    my $r = shift;
    print STDERR "Hey we are here\n";
    $r->log->warn( 'this is a warning' );

    $r->log->warn( $octets );
    $r->log->warn( Encode::decode_utf8( $octets ) );

    print STDERR $octets;

    $r->content_type('text/plain');
    $r->print( "hello world\n" );

    return Apache2::Const::OK();
    }
    }
    </Perl>

    Listen 9090
    <Directory />
    SetHandler modperl
    PerlResponseHandler Foo
    </Directory>
    Hi.

    First, the subject chosen for your email is not going to be much help for someone
    searching the list archives later. Even "Быстрая коричневая лиса" would have been better.

    And second, a "what if.." :
    What if you start Apache under a UTF-8 "locale" ?
    (does it then still escape the non-iso-8859-1 characters in the log ?)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmodperl @
categoriesmodperl, perl
postedSep 23, '14 at 4:29p
activeSep 23, '14 at 6:11p
posts2
users2
websiteperl.apache.org

2 users in discussion

Bill Moseley: 1 post André Warnier: 1 post

People

Translate

site design / logo © 2018 Grokbase