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

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

πŸ’– Log::Handler::Output::Socket β€” the perl manpage but make it cute

okay bestie, so this page is from the User Contributed Perl Documentation section of the manual, and it's all about Log::Handler::Output::Socket. Consider this your group chat briefing. 🫢


✨ NAME ✨

Log::Handler::Output::Socket β€” literally just: send messages to a socket. that's the whole vibe. πŸ’Œ


🌸 SYNOPSIS 🌸

use Log::Handler::Output::Socket;

my $sock = Log::Handler::Output::Socket->new(
    peeraddr    => "127.0.0.1",
    peerport    => 44444,
    proto       => "tcp",
    timeout     => 10
);

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

that's it. that's the whole glow-up. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

with this module you can send messages over the network. yes, like, actually over the network. main character networking energy, no cap. πŸ”₯


πŸ’… METHODS πŸ’…

πŸ”§ new()

call new() to create a new Log::Handler::Output::Socket object. it's giving birth but for objects. πŸŽ€

here are all the options you can pass, bestie β€” don't skip any of them:

  • peeraddr β€” the address of the server. where your message is going, like a little letter. πŸ’Œ
  • peerport β€” the port to connect to. the specific door you're knocking on. πŸšͺ
  • proto β€” the protocol you wish to use. default is TCP. it's giving classic.
  • timeout β€” the timeout to send a message. default is 5 seconds. don't ghost it for too long or it dips. 😭
  • persistent and reconnect β€” with this option you can enable or disable a persistent connection, and re-connect if the connection was lost. both options are set to 1 on default, so they're already on. iconic defaults tbh. ✨
  • dump β€” do you like to dump the message? πŸ‘€ if you enable this option then all messages will be dumped with Data::Dumper. not some. all. periodt.
  • dumper β€” do you want to use another dumper instead of Data::Dumper? yes you can, here's an example:
use Convert::Bencode_XS;

    dumper => sub { Convert::Bencode_XS::bencode($_[0]) }

# or maybe

use JSON::PC;

    dumper => sub { JSON::PC::convert($_[0]) }
  • connect β€” this option is only useful if you want to pass your own arguments to IO::Socket::INET and don't want to use peeraddr and peerhost. it's giving DIY. πŸ› οΈ

example:

        connect => {
            PerrAddr  => "127.0.0.1",
            PeerPort  => 44444,
            LocalPort => 44445
        }

(yes, that's PerrAddr exactly as written, we do not touch the code bestie, copying it character-for-character is the whole assignment πŸ’―)

these options are passed to IO::Socket::INET.

πŸ“¨ log()

call log() if you want to send a message over the socket. this is the moment. the whole reason we're here. πŸ’«

example:

$sock->log("message");

πŸ”Œ connect()

connect to the socket. slay, we're online. 🌈

πŸ›‘ disconnect()

disconnect from the socket. bye bestie, it was real. πŸ‘‹

βœ… validate()

validate a configuration. making sure everything is correct before we commit β€” very mature of you. πŸ’œ

πŸ”„ reload()

reload with a new configuration. it's giving rebrand. ✨

πŸ’€ errstr()

this function returns the last error message. so when something goes wrong, ask errstr() what happened. 😭


πŸŽ€ PREREQUISITES πŸŽ€

these need to be in the building for any of this to work:

Carp
Params::Validate;
IO::Socket::INET;
Data::Dumper;

πŸ“ EXPORTS πŸ“

no exports. nothing to export. empty house. πŸ™ˆ (fr fr, it says "No exports." and it means it.)


🐞 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. that's the rule, don't forget it. πŸ“¬


πŸ‘‘ 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.


just so you know, this page came from the perl v5.36.0 docs, dated 2022-08-28, in the User Contributed Perl Documentation collection. πŸ’–

and that's a wrap, bestie β€” go send some messages over that socket. you got this. πŸ¦‹βœ¨πŸ’…

πŸ“¦ where this page comes from