Agent::Channel(3pm)
π Agent::Channel(3pm) π
okay bestie, welcome to the Perl User Contributed Documentation section, because this one lives in the 3pm manual pages and it's genuinely so iconic. we're talking about Log::Agent::Channel today. grab a strawberry π, sit down, let's get into it.
πΈ NAME πΈ
Log::Agent::Channel β the ancestor class for literally all the Log::Agent channels. the mother of all channels. the blueprint. the blueprint that refuses to be built, but we'll get to that. π
β¨ SYNOPSIS β¨
the vibe is short and sweet, here's the whole thing:
@Log::Agent::Channel::XXX::ISA = qw(Log::Agent::Channel);
that's it. that's the synopsis. she's concise. π
π¦ DESCRIPTION π¦
so Log::Agent::Channel is the root class β every single channel under Log::Agent inherits from her. periodt.
and now the important part, no cap: she's a deferred class, meaning you literally cannot instantiate her directly. not a single time. if you try, that's on you. π every one of the deferred routines has to be implemented by her heirs for them to count as a valid driver. like, you can't just show up un-implemented and call yourself a driver, bestie. do the work.
internally, the various Log::Agent::Driver objects are the ones creating Log::Agent::Channel instances β one for each logging channel defined at driver creation time. so the channels are architecturally hidden inside Log::Agent, because this module only provides redefined mappings for the various logxxx() routines (logerr(), logwarn(), logdie(), etc...). lowkey invisible, highkey doing all the work.
but hold on, don't panic, that does not mean channel classes can't be used externally. the Log::Agent::Logger extension makes Log::Agent::Channel objects architecturally visible, which gives you an application-level logging API that can be redirected to various places β totally transparently for the application. she can be seen now. main character energy. π
π CHANNEL LIST π
here's who's currently showing up to the party, made available by Log::Agent. and btw, more channels can always be defined by the Log::Agent::Logger extension β the guest list is open:
Log::Agent::Channel::Fileβ this channel writes logs to files, defined by their path or via a magical opening sequence such as"|cmd". seeLog::Agent::Channel::File.Log::Agent::Channel::Handleβ this channel writes logs to an already opened descriptor, as specified by its file handle: anIO::Handleobject, or aGLOBreference such as\*FILE. seeLog::Agent::Channel::Handle.Log::Agent::Channel::Syslogβ this channel redirects logs to thesyslogd(8)daemon, which will then handle the dispatching to various logfiles, based on its own configuration. seeLog::Agent::Channel::Syslog.
π«Ά INTERFACE π«Ά
ngl, you genuinely do not need to read this section if you're only using Log::Agent. like, go live your life. but if you wanna implement another channel? then bestie, this part is for you. π
the following routines are deferred, so they absolutely need to be defined by the heir:
write($priority, $logstring)β emit the log entry held in$logstring, at priority$priority. a trailing"\n"is added to the$logstring, if needed (i.e. if the physical entity does not do it already, likesyslogdoes). the$priorityargument must be a valid syslog priority, i.e. one of the following strings:"emerg","alert","crit","err","warning","notice","info","debug". also real talk:$logstringmay not really be a plain string β it can actually be aLog::Agent::Messageobject with an overloaded stringification routine, so the illusion should be complete. β¨ sneaky but make it seamless.closeβ close the channel. bye girl. πmakeβ this is the creation routine. its signature varies for each channel, naturally. obviously. every queen is different. π
π AUTHOR π
Raphael Manfredi <Raphael_Manfredi@pobox.com>
β SEE ALSO β
Log::Agent::Channel::File(3)Log::Agent::Channel::Handle(3)Log::Agent::Channel::Syslog(3)Log::Agent::Logger(3)
and that's the whole page, babe π¦ this was perl v5.36.0, dated 2022-10-15, and it's Agent::Channel(3pm) β stay deferred, never instantiated, forever iconic. mwah. πβ¨
π¦ 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