You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bill Moseley <mo...@hank.org> on 2014/09/23 18:28:24 UTC
undefined
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
Re: undefined
Posted by André Warnier <aw...@ice-sa.com>.
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 ?)