Jeff, > What I was hoping to do was write stuff to the log file for a week or > two using the info() method. Then I could grep out my lines, get > the data analyzed, and then finish the plugin. > > I am a fairly experienced programmer but I have not used object oriented > Perl before. Thankfully it doesn't seem that different from other OO > languages. Anyway I don't mind hacking up a temporary version of > Amavisd if you could tell me how to get SA to quit logging to STDERR.
Ok, here is a patch to amavisd-new 2.5.2 (works with SA 3.2.3), which achieves what you need, or at least should get you going. It hooks its own logging module into SpamAssassin, so it receives all logging from SA. It maps SpamAssassin log levels into amavisd log levels (which in turn are mapped into syslog priorities), so you should be seing for example SA 'info:' at amavisd log level 1, and 'dbg:' at log level 5 (so you must have $log_level=5 in order to see dbg:). Change the mapping to taste if you like. To enable SA logging either $sa_debug must be set, or a non-empty list of SA debug channels need to be specified on a command line, e.g.: # amavisd -d dns,uri,uridnsbl or just: # amavisd -d all The patch: --- amavisd.orig Mon Sep 10 02:02:39 2007 +++ amavisd Fri Sep 21 21:24:34 2007 @@ -17723,4 +17723,35 @@ +package Mail::SpamAssassin::Logger::Amavislog; +use strict; +use re 'taint'; +no warnings 'uninitialized'; +use warnings FATAL => 'utf8'; + +BEGIN { + use Exporter (); + use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION); + $VERSION = '2.091'; + @ISA = qw(Exporter); + # persuade 'require' into believing this module is already loaded: + $INC{'Mail/SpamAssassin/Logger/Amavislog.pm'} = 'amavisd'; + + import Amavis::Util qw(ll do_log); + use vars qw(%map_ll); + %map_ll = ('error' => -1, 'warn' => 0, 'info' => 1, 'dbg' => 5); +} + +sub new { my($class) = shift; bless {}, $class } +sub close_log {} + +sub log_message { + my($self, $level,$msg) = @_; + my($ll) = $map_ll{$level}; + $ll = 1 if !defined($ll); + ll($ll) && do_log($ll, "SA %s: %s", $level,$msg); +} + +1; + package Amavis::SpamControl::SpamAssassin; use strict; @@ -17903,6 +17934,11 @@ $sa_version_num = sprintf("%d.%03d%03d", $1,$2,$3) if $sa_version =~ /^(\d+)\.(\d+)(?:\.(\d+))/; # ignore trailing non-digits + if ($sa_debug || @sa_debug_fac) { + Mail::SpamAssassin::Logger::add(method => 'Amavislog') + or die "Mail::SpamAssassin::Logger::add failed"; + } my($sa_args) = { - debug => !$sa_debug ? undef : @sa_debug_fac ? [EMAIL PROTECTED] : 'all', + debug => !($sa_debug || @sa_debug_fac) ? undef + : @sa_debug_fac ? [EMAIL PROTECTED] : 'all', save_pattern_hits => $sa_debug ne '' ? 1 : 0, dont_copy_prefs => 1, Mark