Appende...t::UNIX(3)

πŸ“¦
version 1.04 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Log::Log4perl::Appender::Socket::UNIX β€” the appender that slides your log lines straight into a Unix Domain Socket ✨

(also known as Appende...t::UNIX(3), from the User Contributed Perl Documentation collection, bestie 🫢)


🌸 SYNOPSIS 🌸

use Log::Log4perl::Appender::Socket::UNIX;

my $appender = Log::Log4perl::Appender::Socket::UNIX->new(
        Socket => '/var/tmp/myprogram.sock'
);

$appender->log(message => "Log me\n");

okay so that's literally it, that's the whole vibe πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So like, this is a simple appender for writing to a unix domain socket. It's leaning on Socket for all the heavy lifting, and here's the tea: it only logs to a socket that already exists. Which is genuinely so useful when you want to always stream your debug output into a socket, no cap 🫢

The appender tries to stream to a socket. And the socket in question? That's being created by the client who wants to listen β€” so once that client has made it, the messages start coming thru. periodt. ✨


πŸŽ€ EXAMPLE πŸŽ€

wanna write a client real quick using the Socket module? bet. here's how:

use Socket;

my $s = "/var/tmp/myprogram.sock";

unlink($s) or die("Failed to unlin socket - check permissions.\n");

# be sure to set a correct umask so that the appender is allowed to stream to:
# umask(000);

socket(my $socket, PF_UNIX, SOCK_DGRAM, 0);
bind($socket, sockaddr_un($s));

while (1) {
        while ($line = <$socket>) {
                print $line;
        }
}
πŸ‘‘ note the little comment in there about setting a correct umask so the appender is allowed to stream to it β€” don't skip that, it's giving main character energy for a reason πŸ™ˆ

Copyright 2012 by Jean Stebens <debian.helba@recursor.net>. 🫢

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


and that's the whole page bestie!! this was perl v5.42.0, dated 2025-07-25, from Appende...t::UNIX(3) β€” mwah, go log something iconic πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from