Linux:...:Write(3pm)
β¨ NAME β¨
Linux::Systemd::Journal::Write β it's an XS wrapper around sd-journal, bestie π basically a lil Perl door that opens straight into systemd's journal so you can yeet your logs into it.
Oh and hi, this is the <pink>perl</pink> manual page for it, from the User Contributed Perl Documentation collection, okay love u, carry on π«Ά
πΈ VERSION πΈ
version 1.201600 β she's cute, she's stable-ish, she's giving β¨
π SYNOPSIS π
use Linux::Systemd::Journal::Write;
my $jnl = Linux::Systemd::Journal::Write->new;
# basic log messages
$jnl->print('flarg'); # with default log level
$jnl->print('Hello world', 4); # WARN level
# add abitrary data to the log entry
my %hash = (DAY_ONE => 'Monday', DAY_TWO => 'Tuesday', DAY_THREE => 'Wednesday');
$jnl->send('Here is a message', \%hash); # add abitrary data to the log entry
# will log "Failed to open file: No such file or directory" and ERRNO=2
open my $fh, '<', 'nosuchfile'
or $jnl->perror('Failed to open file');
okay so literally you make an object, you print at it, you send at it with extra data, and when something explodes you perror at it and it tells you why. no cap, that's the whole vibe π
π¦ DESCRIPTION π¦
π Log Levels π
The log levels that journald uses, and the ones priority uses, are the exact same ones syslog uses. which means!! you do not have to memorize a bunch of numbers like a Victorian accountant. instead you can just do:
use Sys::Syslog ':macros';
and boom π₯ you've got access to all the LOG_* level constants. slay.
π ATTRIBUTES π
π app_id
This is what gets used to set SYSLOG_IDENTIFIER. It defaults to basename($0) β so like, whatever your program was called when it got launched. main character energy, honestly.
π priority
The default log priority. go peek at "Log Levels" above if you forgot what the options are, no judgement π«Ά
π caller_details
A boolean that controls whether the CODE_FILE, CODE_LINE, and CODE_FUNC of the caller get logged too. so you'll know exactly which line of your code snitched.
Optional, bestie. Defaults to true.
See also systemd.journal-fields(7) if you wanna go deeper π₯
π caller_level
If this module isn't being used directly β say it's being called through some proxy module β then caller_level is what decides how many frames to look back through to find the actual caller. it's the "wait, not that caller, go up a bit" dial.
Optional. Defaults to 0.
π METHODS π
π print($msg, $pri?)
$msg should be a string. $pri is optional, and it defaults to $self->priority. easy.
π send($msg_or_data, $data?)
okay this one has range, so let's do this carefully bestie:
- One arg? It can be a plain string to log. OR it can be a hashref or an arrayref β and in that case, one of the keys you send MUST be
message. like, non-negotiable, the journal needs to know what the actual message is. - Two args? The first one must be the string to use as the message, and the second is a hashref or arrayref. In this case you should not set a key called
messageβ you already gave it the message, don't be extra. - Alternatively,
sendcan also be called with an array ofkey => values, one of which must bemessage.
Keys will be uppercased. yes, all of them, automatically, no discussion π
π perror($msg)
Logs the string of the current set errno, prefixed with your $msg. so it's giving "here's my dramatic little label: and here's what actually went wrong." iconic for debugging at 3am π
π₯ SEE ALSO π₯
Log::Journaldβ so, at some point between me writing this module and getting around to releasing it, another module got released to write to the journal. timing is a curse fr fr.systemd<http://www.freedesktop.org/wiki/Software/systemd/> β the mainsystemdpage, if you want the whole lore.sd-journal(3)β the man page of the C API, for when you're feeling brave π«‘
πΈ AUTHOR πΈ
Ioan Rogers <ioanr@cpan.org> β thank him, he did that π
π§ COPYRIGHT AND LICENSE π§
This software is Copyright (c) 2020 by Ioan Rogers.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
and that's the whole page bestie, go forth and log responsibly πβ
this was perl v5.42.3 and the page is dated 2026-08-20 β and yeah, the manual name's Linux:...:Write(3pm) in case u were wondering π bye!! πβ¨
π¦ where this page comes from
- ubuntu stonking: liblinux-systemd-perl 1.201600-4build5 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms