[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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");