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 1 if a message at a given level and facility would be logged normally.
  • Returns 2 if 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