https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6228

--- Comment #12 from Anthony Foiani <[email protected]> 2009-12-16 
23:42:22 UTC ---
In the process of tracking down this bug, I made these modifications to
SpamAssassin::Logger.  They helped me navigate the code (especially all the
twisty calls that the plugin architecture generates).  This is probably too
verbose for most output, but I thought it might be worth putting here so that
someone could make it an option if they were so inclined.

Just before "sub _loc":

my %short_name_of_file; 

sub _loc_from_caller 
{ 
  my ($package, $file, $line) = @_; 
  unless ( $short_name_of_file{$file} ) 
  { 
    my ( $short_name ) = ( $file =~ m!Mail/(SpamAssassin.*)$! ); 
    $short_name_of_file{$file} = $short_name || $file; 
  } 
  return "$short_name_of_file{$file}($line)"; 
} 

And inside "sub _loc", just before the call to log_message:

  if (my @parent = caller 1 ) 
  { 
      my $loc = _loc_from_caller @parent; 
      if (my @grandparent = caller 2) 
      { 
          $loc = _loc_from_caller(@grandparent) . " -> $loc"; 
      } 
      $message =~ s/^/[$loc] /mg; 
  } 

That makes for very wide log messages (and probably a bit slower), but it was
invaluable in figuring out just how I got to certain log message.

Thanks!

-- 
Configure bugmail: 
https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to