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 !$^S;
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
23 reference (the key names are used), an array reference, an array,
24 or a comma-separated scalar string. Facility names are case-
25 sensitive.
26
27 If "all" is listed, then all debug facilities are implicitly
28 enabled, except for those explicitly disabled. A facility name may
29 be preceded by a "no" (case-insensitive), which explicitly disables
30 it, overriding the "all". For example: all,norules,noconfig,nodcc.
31 When facility names are given as an ordered list (array or scalar,
32 not a hash), the last entry applies, e.g. 'nodcc,dcc,dcc,noddc' is
33 equivalent to 'nodcc'. Note that currently no facility name starts
34 with a "no", it is advised to keep this practice with newly added
35 facility names to make life easier.
36
37 Higher priority informational messages that are suitable for
38 logging in normal circumstances are available with an area of
39 "info". Some very verbose messages require the facility to be
40 specifically enabled (see "would_log" below).
41
42 log_message($level, @message)
43 Log a message at a specific level. Levels are specified as
44 strings: "warn", "error", "info", and "dbg". The first element of
45 the message must be prefixed with a facility name followed directly
46 by a colon.
47
48 dbg("facility: message")
49 This is used for all low priority debugging messages.
50
51 info("facility: message")
52 This is used for informational messages indicating a normal, but
53 significant, condition. This should be infrequently called. These
54 messages are typically logged when SpamAssassin is run as a daemon.
55
56 add(method => 'syslog', socket => $socket, facility => $facility)
57 "socket" is the type the syslog ("unix" or "inet"). "facility" is
58 the syslog facility (typically "mail").
59
60 add(method => 'file', filename => $file)
61 "filename" is the name of the log file.
62
63 add(method => 'stderr')
64 No options are needed for stderr logging, just don't close stderr
65 first.
66
67 remove(method)
68 Remove a logging method. Only the method name needs to be passed
69 as a scalar.
70
71 would_log($level, $facility)
72 Returns false if a message at the given level and with the given
73 facility would not be logged. Returns 1 if a message at a given
74 level and facility would be logged normally. Returns 2 if the
75 facility was specifically enabled.
76
77 The facility argument is optional.
78
79 close_log()
80 Close all logs.
81
82
83
84perl v5.30.0 2019-10-01 Mail::SpamAssassin::Logger(3)