[Omaha.pm] Binary stuff in my logs (Log::Log4perl)

Sean Baker pbaker at omnihotels.com
Wed Sep 27 14:39:46 PDT 2006


Or maybe any of this:

If you need to find out if the currently configured logging level would
allow a logger's logging statement to go through, use the logger's
is_level() methods:

    $logger->is_debug()    # True if debug messages would go through
    $logger->is_info()     # True if info messages would go through
    $logger->is_warn()     # True if warn messages would go through
    $logger->is_error()    # True if error messages would go through
    $logger->is_fatal()    # True if fatal messages would go through

http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4
perl.html#d12d5


Sean Baker

-----Original Message-----
From: omaha-pm-bounces+pbaker=omnihotels.com at pm.org
[mailto:omaha-pm-bounces+pbaker=omnihotels.com at pm.org] On Behalf Of Jay
Hannah
Sent: Wednesday, September 27, 2006 4:13 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Binary stuff in my logs (Log::Log4perl)


Log::Log4perl follow-up...

Hmmm... Now I'm wishing there was a way to ask a Log::Log4perl object if
there are any debug level listeners active.... What a waste of CPU if
debug() is being ignored...

j

 
# -----
# Send this to the debugger in case someone is listening...
# If there's binary crap in here don't write that to my logs.
# Instead, throw [ASCII:24] and the like to the logs.
#   Wow... This is a terrible loop if we ever send more than a 
#   few bytes of binary data through the engine!!
# -jhannah 2006-09-27
# -----
my $logable_buffer = $self->{buffer};
my $binary_char;
while (($binary_char) = ($logable_buffer =~ /([^ -~])/)) {
   my $ord = "[ASCII:" . ord($binary_char) . "]";
   $logable_buffer =~ s/\Q$binary_char\E/$ord/gs;
}
$logger->debug("My buffer is now $logable_buffer");

_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



More information about the Omaha-pm mailing list