Log::H...ndmail(3pm)

πŸ“¦
version 0.90 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’Œ Log::Handler::Output::Sendmail

okay so before anything else: this is the manual page for Log::Handler::Output::Sendmail, section 3pm, from the User Contributed Perl Documentation. It's the girl who emails your logs for you. No cap. πŸ¦‹


✨ NAME ✨

Log::Handler::Output::Sendmail β€” log messages with sendmail. that's it, that's the whole name. πŸ’–


🌸 SYNOPSIS 🌸

use Log::Handler::Output::Sendmail;

my $email = Log::Handler::Output::Sendmail->new(
    from    => 'bar@foo.example',
    to      => 'foo@bar.example',
    subject => 'your subject',
);

$email->log(message => $message);

look at her. so clean. so iconic. πŸ‘‘


🫢 DESCRIPTION 🫢

With this output module it's possible to log messages via "sendmail". that's the whole vibe: your log line walks into the sendmail command and leaves as an actual email. main character energy fr fr. ✨


πŸ’… METHODS πŸ’…

new()

Call new() to create a brand new Log::Handler::Output::Sendmail object. fresh out the box. πŸŽ€

The following options are possible:

  • from β€” the sender address (From). who's writing the letter bestie.
  • to β€” the receipient address (To). who's getting it. πŸ’Œ
  • cc β€” Carbon Copy (Cc).
  • bcc β€” Blind Carbon Copy (Bcc). sneaky. πŸ™ˆ
  • subject β€” the subject of the mail.
  • sender β€” this option is identical with sendmail -f.
  • header β€” with this options it's possible to set your own header. and you have THREE flavors of doing it, pick your fighter:
my $email = Log::Handler::Output::Sendmail->new(
    from   => 'bar@foo.example',
    to     => 'foo@bar.example',
    header => 'Content-Type: text/plain; charset= UTF-8',
);

Or

my $email = Log::Handler::Output::Sendmail->new(
    header => {
        From    => 'bar@foo.example',
        To      => 'foo@bar.example',
        Subject => 'my subject',
        'Content-Type' => text/plain; charset= UTF-8',
    }
);

Or

my $email = Log::Handler::Output::Sendmail->new(
    header => [
        'From: bar@foo.example',
        'To: foo@bar.example',
        'Subject: my subject',
        'Content-Type: text/plain; charset= UTF-8',
    ]
);

(yeah bestie, those examples are copied character-for-character, typos and all, we don't fix canon in this house πŸ’€)

  • sendmail β€” the default is set to /usr/sbin/sendmail.
  • params β€” parameters for "sendmail". The default is set to -t.
  • maxsize β€” set the maximum size of the buffer in bytes. All messages will be buffered and if "maxsize" is exceeded the buffer is flushed and the messages will be send as email. The default is set to 1048576 bytes. Set 0 if you want no buffering and send a mail for each log message. (chaotic, but valid. 😌)
  • debug β€” set 1 if you want to enable debugging. The messages can be fetched with $SIG{__WARN__}.
ngl the header option alone is giving options-within-options. obsessive in the best way. πŸ’…

log()

Call log() if you want to log a message as email.

$email->log(message => "this message will be mailed");

If you pass the level then its placed into the subject:

$email->log(message => "foo", level => "INFO");
$email->log(message => "bar", level => "ERROR");
$email->log(message => "baz", level => "DEBUG");

The lowest level is used:

Subject: ERROR ...

You can pass the level with "Log::Handler" by setting

message_pattern => '%L'

so like, the loudest problem wins the subject line. iconic behavior tbh. πŸ”₯

flush()

Call flush() if you want to flush the buffered messages. go on, let them out. πŸ¦‹

validate()

Validate a configuration. πŸŽ€

reload()

Reload with a new configuration. glow-up time. ✨

errstr()

This function returns the last error message. receipts, basically. 🧾


πŸ’€ DESTROY πŸ’€

"DESTROY" is defined and called "flush()".

so when she leaves the party, she flushes the buffer on the way out. no leftover messages, no mess. periodt.

🌈 PREREQUISITES 🌈

  • Carp
  • Params::Validate

πŸŽ€ EXPORTS πŸŽ€

No exports. she keeps it to herself. 🫢


πŸ› REPORT BUGS πŸ›

Please report all bugs to <jschulz.cpan(at)bloonix.de>.

If you send me a mail then add Log::Handler into the subject. (bestie please, otherwise it's lost in the void 😭)


πŸ‘‘ AUTHOR πŸ‘‘

Jonny Schulz <jschulz.cpan(at)bloonix.de>.


Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie πŸ’– this one shipped with perl v5.36.0 and is dated 2022-08-28 β€” go forth and email your logs, you absolute legend. slay. πŸŒΈπŸ‘‘

πŸ“¦ where this page comes from