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

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

πŸ’– Log::Handler::Output::Forward πŸ’–

okay bestie, so this is a 3pm Perl module page β€” part of the Log::Handler squad β€” and it's literally just a lil messenger that forwards your log messages to a subroutine. That's it. That's the whole vibe. ✨


🌸 NAME 🌸

Log::Handler::Output::Forward β€” forward messages to routines. fr fr, that's the entire job description. πŸ’…


✨ SYNOPSIS ✨

here's the whole thing in action, no notes:

use Log::Handler::Output::Forward;

my $forwarder = Log::Handler::Output::Forward->new(
    forward_to => sub { },
    arguments  => [ "foo" ],
);

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

that's it. that's the plot. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so this output module makes it possible to forward messages to sub routines. that's the whole point of it existing. it catches your messages and just, like, hands them off to whatever code ref you told it to hand them off to. main character energy tbh. πŸ‘‘


πŸ’… METHODS πŸ’…

πŸŽ€ new()

call new() to create a new Log::Handler::Output::Forward object. iconic. here are the options you can pass it:

  • forward_to β€” this option excepts a code reference. (yes, the original says "excepts", we keep the facts, we keep the typo, we move on πŸ’€)
⚠️ please note that the message is forwarded as a hash reference. if you change it then this would have an effect to all outputs. so like, don't go editing it unless you mean to, bestie. πŸ™ˆ
  • arguments β€” with this option you can define arguments that will be passed to the sub routine.

in this next example the arguments would be passed as a array to Class::method():

my $forwarder = Log::Handler::Output::Forward->new(
    forward_to => \&Class::method,
    arguments  => [ $self, "foo" ],
);

this would call intern:

Class::method(@arguments, $message);

and if this option is not set, then the message will be passed as first argument. simple as. ⭐

πŸ“ log()

call log() if you want to forward messages to the subroutines. that's the moment. the slay moment.

Example:

$forwarder->log("this message will be forwarded to all sub routines");

🌈 validate()

validate a configuration. (yes queen, check that config before you commit to it)

🧚 reload()

reload with a new configuration. glow-up but for settings.

πŸ’œ errstr()

this function returns the last error message. so when something goes wrong you can go πŸ‘€ and ask it.


πŸ’Œ FORWARDED MESSAGE πŸ’Œ

note that the message will be forwarded as a hash reference.

if you make changes to the reference it affects all other outputs. (say it with me: shared state is a group project and everyone gets the consequences 😭)

the hash key message contains the message.


πŸ‘‘ PREREQUISITES πŸ‘‘

Carp
Params::Validate

🌟 EXPORTS 🌟

no exports. nothing. zero. we keep it minimal bestie. πŸŽ€


πŸ› 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. (subject line matters, iykyk πŸ“§)


🌸 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's perl v5.36.0, dated 2022-08-28, from the Log::H...Forward(3pm) corner of the manual. go forth and forward your messages responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from