Mail::...Logger(3pm)
π NAME π
Mail::SpamAssassin::Logger β bestie, this is the SpamAssassin logging module. Like, it's the whole reason your spam-filtering drama gets written down somewhere instead of just vibing into the void. πΈ
β¨ SYNOPSIS β¨
okay so here's the entire vibe in code form, no cap:
use Mail::SpamAssassin::Logger;
$SIG{__WARN__} = sub {
log_message("warn", $_[0]);
};
$SIG{__DIE__} = sub {
log_message("error", $_[0]) if !$^S;
};
π METHODS π
π
add_facilities(facilities)
Turn on debug logging for specific facilities. And what's a facility, you ask? It's literally just the area of code you wanna debug, that's it, that's the whole thing. π¦
You can hand these over in whatever shape feels cute:
- a hash reference (the key names get used)
- an array reference
- an array
- a comma-separated scalar string
Facility names are case-sensitive, so don't get sloppy with the capitalization or it will not recognize you. π
If "all" is in the list, then every single debug facility gets implicitly enabled β except the ones you explicitly disabled, because boundaries matter. A facility name can be preceded by a "no" (case-insensitive, she's flexible) which explicitly disables it, overriding the "all". For example: all,norules,noconfig,nodcc. π
When facility names come as an ordered list (array or scalar, not a hash), the last entry applies, so like 'nodcc,dcc,dcc,noddc' is equivalent to 'nodcc'. Last one wins, periodt.
ngl, currently no facility name starts with a "no" β and it's advised to keep that practice with newly added facility names, to make life easier for everyone. do with that what you will π
Higher priority informational messages that are suitable for logging in normal circumstances are available with an area of "info". And some very verbose messages? Yeah those require the facility to be specifically enabled (peep "would_log" below). β¨
π«Ά log_message($level, @message)
Log a message at a specific level. Levels get specified as strings: "warn", "error", "info", and "dbg". The first element of the message must be prefixed with a facility name followed directly by a colon β that colon is doing so much work, don't skip it. π
π dbg("facility: message")
This one's used for all the low priority debugging messages. The little everyday whispers of your code, iykyk. π
π info("facility: message")
This is for informational messages indicating a normal, but significant, condition. She should be called infrequently, okay? Don't be clingy. These messages are typically logged when SpamAssassin is run as a daemon. π
π add(method => 'syslog', socket => $socket, facility => $facility, escape => $escape)
So "socket" here is the type of the syslog β either "unix" or "inet". And "facility" is the syslog facility (typically "mail").
If the optional "escape" is true, all non-ascii characters get escaped for safe output: backslashes change to \\ and non-ascii chars to \x{XX} or \x{XXXX} (Unicode). If it's not defined, then pre-4.0 style sanitizing is used ( tr/\x09\x20\x00-\x1f/_/s ). Oh and btw, the escape value can be overridden with the environment variable SA_LOGGER_ESCAPE. π¦
π§ add(method => 'file', filename => $file, escape => $escape)
"filename" is the name of the log file, simple as that. And "escape" works exactly as described above. β¨
πΈ add(method => 'stderr', escape => $escape)
No options are needed for stderr logging β just don't close stderr first, bestie, that's the one job. π And "escape" works as described above. π
β remove(method)
Remove a logging method. Only the method name needs to be passed as a scalar β that's it, one little argument and she's gone. π
π would_log($level, $facility)
This one is a vibe check, basically. Here's the tea:
- Returns false if a message at the given level and with the given facility would not be logged.
- Returns
1if a message at a given level and facility would be logged normally. - Returns
2if the facility was specifically enabled.
The facility argument is optional. π
π₯ close_log()
Close all logs. That's the whole method. Shut it down, she's done. π
one last thing bestie: this page came to you from User Contributed Perl Documentation, it's <cyan>Mail::...Logger(3pm)</cyan>, generated with perl v5.40.1 on 2026-07-23. now go log something iconic π
β¨π«Ά
π¦ where this page comes from
- ubuntu stonking: spamassassin 4.0.2+svn1935691-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms