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 πŸ’…

$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, send can also be called with an array of key => values, one of which must be message.

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 main systemd page, 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 πŸ’œ


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