Mailing List Archive

svn commit: r109552 - /spamassassin/trunk/lib/Mail/SpamAssassin.pm /spamassassin/trunk/spamd/spamd.raw
Author: mss
Date: Thu Dec 2 13:36:57 2004
New Revision: 109552

URL: http://svn.apache.org/viewcvs?view=rev&rev=109552
Log:
Made it possible to replace all the warn() kludges in spamd with dbg() or info() calls.

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin.pm
spamassassin/trunk/spamd/spamd.raw

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
Url: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin.pm?view=diff&rev=109552&p1=spamassassin/trunk/lib/Mail/SpamAssassin.pm&r1=109551&p2=spamassassin/trunk/lib/Mail/SpamAssassin.pm&r2=109552
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Thu Dec 2 13:36:57 2004
@@ -243,16 +243,8 @@
if (!defined $self) { $self = { }; }
bless ($self, $class);

- # define debugging facilities first
- $INFO = 0;
- $DEBUG = 0;
- if (defined $self->{debug} && ref($self->{debug}) eq "ARRAY") {
- $facilities{$_} = 1 for @{ $self->{debug} };
- # turn on informational notices
- $INFO = 1 if keys %facilities;
- # turn on debugging if facilities other than "info" are enabled
- $DEBUG = keys %facilities && !(keys %facilities == 1 && $facilities{info});
- }
+ # enable or disable debugging
+ Mail::SpamAssassin::_init_debugger(ref $self->{debug} eq 'ARRAY' ? @{ $self->{debug} } : ());

# first debugging information possibly printed should be the version
info("generic: SpamAssassin version ".Version());
@@ -280,6 +272,25 @@

$self;
}
+
+# Do not use this routine in any 3rd-party scripts, it's not part of the
+# official public API! spamd needs it though.
+#
+# Enables or disables debugging based on the facilities given. This will
+# affect ALL SpamAssassin objects!
+sub _init_debugger {
+ # define debugging facilities first
+ $INFO = 0;
+ $DEBUG = 0;
+ if (@_) {
+ $facilities{$_} = 1 for @_;
+ # turn on informational notices
+ $INFO = 1 if keys %facilities;
+ # turn on debugging if facilities other than "info" are enabled
+ $DEBUG = keys %facilities && !(keys %facilities == 1 && $facilities{info});
+ }
+}
+

sub create_locker {
my ($self) = @_;

Modified: spamassassin/trunk/spamd/spamd.raw
Url: http://svn.apache.org/viewcvs/spamassassin/trunk/spamd/spamd.raw?view=diff&rev=109552&p1=spamassassin/trunk/spamd/spamd.raw&r1=109551&p2=spamassassin/trunk/spamd/spamd.raw&r2=109552
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Thu Dec 2 13:36:57 2004
@@ -217,7 +217,7 @@
'auto-whitelist|whitelist|a' => sub { warn "The -a option has been removed. Please look at the use_auto_whitelist config option instead.\n"; exit 2; },

) or print_usage_and_exit();
-
+
if ($opt{'help'}) {
print_usage_and_exit(qq{For more details, use "man spamd".\n}, 'EX_OK');
}
@@ -226,6 +226,25 @@
exit($resphash{'EX_OK'});
}

+
+# Enable debugging, if any areas were specified. We do this already here,
+# accessing some non-public API so we can use the convenient dbg() routine.
+my @DEBUG;
+if (defined $opt{'debug'}) {
+ if ($opt{'debug'}) {
+ @DEBUG = split(/,/, $opt{'debug'});
+ if (grep { !/^\S+$/ } @DEBUG) {
+ warn "bad areas in --debug option\n";
+ }
+ }
+ else {
+ @DEBUG = ("all");
+ }
+}
+# Don't do this at home (aka any 3rd party tools), kids!
+Mail::SpamAssassin::_init_debugger(@DEBUG);
+
+
# bug 2228: make the values of (almost) all parameters which accept file paths
# absolute, so they are still valid after daemonize()
foreach my $opt (
@@ -728,19 +747,6 @@
Mail::SpamAssassin::Util::untaint_file_path( $opt{'pidfile'} );
}

-# set debug areas, if any specified (only useful for command-line tools)
-my @debug;
-if (defined $opt{'debug'}) {
- if ($opt{'debug'}) {
- @debug = split(/,/, $opt{'debug'});
- if (grep { !/^\S+$/ } @debug) {
- warn "bad areas in --debug option\n";
- }
- }
- else {
- @debug = ("all");
- }
-}

my $spamtest = Mail::SpamAssassin->new(
{
@@ -748,7 +754,7 @@
rules_filename => ( $opt{'configpath'} || 0 ),
site_rules_filename => ( $opt{'siteconfigpath'} || 0 ),
local_tests_only => ( $opt{'local'} || 0 ),
- debug => \@debug,
+ debug => \@DEBUG,
paranoid => ( $opt{'paranoid'} || 0 ),
home_dir_for_helpers => (
defined $opt{'home_dir_for_helpers'}