1Mail::SpamAssassin::LogUgseerr(3C)ontributed Perl DocumeMnatialt:i:oSnpamAssassin::Logger(3)
2
3
4
6 Mail::SpamAssassin::Logger - SpamAssassin logging module
7
9 use Mail::SpamAssassin::Logger;
10
11 $SIG{__WARN__} = sub {
12 log_message("warn", $_[0]);
13 };
14
15 $SIG{__DIE__} = sub {
16 log_message("error", $_[0]) if $_[0] !~ /\bin eval\b/;
17 };
18
20 add_facilities(facilities)
21 Enable debug logging for specific facilities. Each facility is the
22 area of code to debug. Facilities can be specified as a hash ref‐
23 erence (the key names are used), an array reference, an array, or a
24 comma-separated scalar string.
25
26 If "all" is listed, then all debug facilities are enabled. Higher
27 priority informational messages that are suitable for logging in
28 normal circumstances are available with an area of "info". Some
29 very verbose messages require the facility to be specifically
30 enabled (see "would_log" below).
31
32 log_message($level, $message)
33 log_message($level, @message)
34 Log a message at a specific level. Levels are specified as
35 strings: "warn", "error", "info", and "dbg". The first element of
36 the message must be prefixed with a facility name followed directly
37 by a colon.
38
39 dbg("facility: message")
40 This is used for all low priority debugging messages.
41
42 info("facility: message")
43 This is used for informational messages indicating a normal, but
44 significant, condition. This should be infrequently called. These
45 messages are typically logged when SpamAssassin is run as a daemon.
46
47 add(method => 'syslog', socket => $socket, facility => $facility)
48 "socket" is the type the syslog ("unix" or "inet"). "facility" is
49 the syslog facility (typically "mail").
50
51 add(method => 'file', filename => $file)
52 "filename" is the name of the log file.
53
54 add(method => 'stderr')
55 No options are needed for stderr logging, just don't close stderr
56 first.
57
58 remove(method)
59 Remove a logging method. Only the method name needs to be passed
60 as a scalar.
61
62 would_log($level, $facility)
63 Returns 0 if a message at the given level and with the given facil‐
64 ity would be logged. Returns 1 if a message at a given level and
65 facility would be logged normally. Returns 2 if the facility was
66 specifically enabled.
67
68 The facility argument is optional.
69
70 close_log()
71 Close all logs.
72
73
74
75perl v5.8.8 2008-01-05 Mail::SpamAssassin::Logger(3)