You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2009/06/08 17:36:30 UTC
svn commit: r782679 - /spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm
Author: mmartinec
Date: Mon Jun 8 15:36:30 2009
New Revision: 782679
URL: http://svn.apache.org/viewvc?rev=782679&view=rev
Log:
M::S::Logger::log_message - insert a '[...]' into continuation lines
of a multiline debug messages, turning a puzzling log line like:
dbg: rules Message-Id: "
into a more obvious:
dbg: rules: ran header rule __MSOE_MID_WRONG_CASE ======> got hit: "
dbg: rules: [...] Message-Id: "
Also, do not require a space to follow a colon after a facility name
in debug messages, the space is not required by documentation:
| Log a message at a specific level. Levels are specified as strings:
| "warn", "error", "info", and "dbg". The first element of the message
| must be prefixed with a facility name followed directly by a colon.
Not that a missing space would be encouraged or actually practiced,
but it shouldn't be treated as a missing facility name.
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm?rev=782679&r1=782678&r2=782679&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm Mon Jun 8 15:36:30 2009
@@ -133,8 +133,6 @@
}
}
-=item log_message($level, $message)
-
=item log_message($level, @message)
Log a message at a specific level. Levels are specified as strings:
@@ -174,10 +172,17 @@
# split on newlines and call log_message multiple times; saves
# the subclasses having to understand multi-line logs
+ my $first = 1;
foreach my $line (split(/\n/, $message)) {
# replace control characters with "_", tabs and spaces get
# replaced with a single space.
$line =~ tr/\x09\x20\x00-\x1f/ _/s;
+ if ($first) {
+ $first = 0;
+ } else {
+ local $1;
+ $line =~ s/^([^:]+?):/$1: [...]/;
+ }
while (my ($name, $object) = each %{ $LOG_SA{method} }) {
$object->log_message($level, $line);
}
@@ -216,7 +221,7 @@
# it's faster to access this as the $_[1] alias, and not to perform
# string mods until we're sure we actually want to log anything
- if ($_[1] =~ /^([^:]+?): /) {
+ if ($_[1] =~ /^([^:]+?):/) {
$facility = $1;
} else {
$facility = "generic";
@@ -231,7 +236,7 @@
}
my ($level, $message, @args) = @_;
- $message =~ s/^([^:]+?): //;
+ $message =~ s/^([^:]+?):\s*//;
if (@args && index($message,'%') >= 0) { $message = sprintf($message,@args) }
$message =~ s/\n+$//s;