Agent:...Handle(3pm)
π Log::Agent::Channel::Handle β the I/O handle logging channel for Log::Agent π
okay bestie so this is Log::Agent::Channel::Handle, a lil Perl module from the User Contributed Perl Documentation corner of the world, and it's literally the thing that lets Log::Agent yell into an I/O handle you already opened. let's get into it π«Ά
β¨ SYNOPSIS β¨
require Log::Agent::Channel::Handle;
my $driver = Log::Agent::Channel::Handle->make(
-prefix => "prefix",
-stampfmt => "own",
-showpid => 1,
-handle => \*FILE,
);
like. that's it. that's the whole vibe. πΈ
π DESCRIPTION π
okay so the handle channel does one thing and it does it iconically: it logs to an already opened I/O handle, and it handles all the necessary prefixing and stamping of the messages on the way out. no cap. π
the creation routine make() takes the following arguments, and yes we're going through every single one because that's the whole point:
-handle=> handle β specifies the I/O handle to use π. it can be given as a GLOB reference, like\*FILE, or as anIO::Handleobject. super flexible, we love that for us.
β οΈ NOTE: auto-flushing is not enabled on the handle. and even when the channel is closed, the handle is left as-is β we literally just stop sending log messages to it. that's it, that's the break-up, no further changes to your handle, periodt.
-no_newline=> flag β when you set this to true, we never append any"\n"(on Unix) or"\r\n"(on Windows) to log messages π«π.
internals tea: Log::Agent relies on the channel to delimit logged lines appropriately, so this flag is not used. however, it might be useful for Log::Agent::Logger users. so like, it's here if you need it iykyk.
default is false, meaning newline markers are systematically appended. π
-no_prefixing=> flag β when true, the prefixing logic is disabled entirely, i.e. these options are ignored completely:-prefix,-showpid,-no_ucfirst,-stampfmt. all of them. gone. ghosted. π»
default is false.
-no_ucfirst=> flag β when true, don't upper-case the first letter of the log message entry when there's no prefix inserted before the logged line. because when there is a prefix, a":"character follows, and therefore the leading letter of the message should not be upper-cased anyway. grammar girlies rise π
default is false, meaning uppercasing is performed.
-prefix=> prefix β the application prefix string to prepend to messages. that's it, that's the assignment. β¨-showpid=> flag β if true, the PID of the process gets appended within square brackets after the prefix, on all messages. main character energy, every line knows whose it is π
default is false.
-stampfmt=> (name | CODE) β specifies the time stamp format to use π. by default, the"own"format is used. seeLog::Agent::Stampingfor a description of the available format names.
you may also specify a CODE ref: that routine will be called every time we need to compute a time stamp. it should not expect any parameter, and should return a string. custom timestamps, slay π
π¨ CAVEAT π¨
beware of chdir(). fr fr. π
if your program uses chdir(), you should always specify logfiles by using absolute paths, otherwise you run the risk of having your relative paths become invalid: there is no anchoring done at the time you specify them.
this is especially true when configured for rotation, since the logfiles are recreated as needed and you might end up with many logfiles scattered throughout all the directories you chdir()ed to. π a whole trail of chaos. use absolute paths bestie i am begging π«Ά
π AUTHOR π
Raphael Manfredi <Raphael_Manfredi@pobox.com>
π¦ SEE ALSO π¦
and that's the page gorgeous β¨ it's Perl v5.36.0, dated 2022-10-15, from the User Contributed Perl Documentation β so like, if you ever forget a flag, this is your girl π mwah, go log something ππ
π¦ where this page comes from
- ubuntu noble: liblog-agent-perl 1.005-2 Β· Artistic-2.0
- ubuntu resolute: liblog-agent-perl 1.005-2 Β· Artistic-2.0
- ubuntu stonking: liblog-agent-perl 1.005-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms