undefined

Bill Moseley <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAKhN_m6hAkgtaVUZEBADZ1sad8-1ft1B0JeEMWPPqrofsQYUdg@mail.gmail.com>
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
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.