.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Log::Agent::Logger 3pm" .TH Log::Agent::Logger 3pm "2021-09-27" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Log::Agent::Logger \- a logging interface .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& require Log::Agent::Logger; \& \& my $log = Log::Agent::Logger\->make( \& \-channel => $chan, \& \-max_prio => \*(Aqinfo\*(Aq, \& \-min_prio => \*(Aqemerg\*(Aq, \& ); \& \& $log\->error("can\*(Aqt open file %s: $!", $file); \& $log\->warning("can\*(Aqt open file: $!"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Log::Agent::Logger\*(C'\fR class defines a generic interface for application logging. It must not be confused with the interface provided by Log::Agent, which is meant to be used by re-usable modules that do not wish to commit on a particular logging method, so that they remain true building blocks. .PP By contrast, \f(CW\*(C`Log::Agent::Logger\*(C'\fR explicitly requests an object to be used, and that object must commit upon the logging channel to be used, at creation time. .PP Optionally, minimum and maximum priority levels may be defined (and changed dynamically) to limit the messages to effectively log, depending on the advertised priority. The standard \fBsyslog\fR\|(3) priorities are used. .SH "CHANNEL LIST" .IX Header "CHANNEL LIST" The following channels are available: .SS "Standard Log::Agent Channels" .IX Subsection "Standard Log::Agent Channels" Those channels are documented in Log::Agent::Channel. .SS "Other Channels" .IX Subsection "Other Channels" Future \f(CW\*(C`Log::Agent::Logger\*(C'\fR extension will extend the set of available channels. .SH "INTERFACE" .IX Header "INTERFACE" .SS "Creation Routine" .IX Subsection "Creation Routine" The creation routine is called \f(CW\*(C`make\*(C'\fR and takes the following switches: .ie n .IP """\-caller"" => [ \fIparameters\fR ]" 4 .el .IP "\f(CW\-caller\fR => [ \fIparameters\fR ]" 4 .IX Item "-caller => [ parameters ]" Request that caller information (relative to the \->\fBlog()\fR call) be part of the log message. The given \fIparameters\fR are handed off to the creation routine of \f(CW\*(C`Log::Agent::Tag::Caller\*(C'\fR and are documented there. .Sp I usually say something like: .Sp .Vb 1 \& \-caller => [ \-display => \*(Aq($sub/$line)\*(Aq, \-postfix => 1 ] .Ve .Sp which I find informative enough. On occasion, I found myself using more complex sequences. See Log::Agent::Tag::Caller. .ie n .IP """\-channel""" 4 .el .IP "\f(CW\-channel\fR" 4 .IX Item "-channel" This defines the \f(CW\*(C`Log::Agent::Channel\*(C'\fR to be used for logging. Please refer to Log::Agent::Channel for details, and in particular to get a list of pre-defined logging channels. .ie n .IP """\-min_prio""" 4 .el .IP "\f(CW\-min_prio\fR" 4 .IX Item "-min_prio" Defines the minimum priority to be logged (included). Defaults to \*(L"emerg\*(R". .ie n .IP """\-max_prio""" 4 .el .IP "\f(CW\-max_prio\fR" 4 .IX Item "-max_prio" Defines the maximum priority to be logged (included). Defaults to \*(L"debug\*(R". .ie n .IP """\-priority"" => [ \fIparameters\fR ]" 4 .el .IP "\f(CW\-priority\fR => [ \fIparameters\fR ]" 4 .IX Item "-priority => [ parameters ]" Request that message priority information be part of the log message. The given \fIparameters\fR are handed off to the creation routine of \f(CW\*(C`Log::Agent::Tag::Priority\*(C'\fR and are documented there. .Sp I usually say something like: .Sp .Vb 1 \& \-priority => [ \-display => \*(Aq[$priority]\*(Aq ] .Ve .Sp which will display the whole priority name at the beginning of the messages, e.g. \*(L"[warning]\*(R" for a \fBwarn()\fR or \*(L"[error]\*(R" for \fBerror()\fR. See Log::Agent::Tag::Priority and Log::Agent::Priorities. .ie n .IP """\-tags"" => [ \fIlist of \f(CI""Log::Agent::Tag""\fI objects\fR ]" 4 .el .IP "\f(CW\-tags\fR => [ \fIlist of \f(CILog::Agent::Tag\fI objects\fR ]" 4 .IX Item "-tags => [ list of Log::Agent::Tag objects ]" Specifies user-defined tags to be added to each message. The objects given here must inherit from \f(CW\*(C`Log::Agent::Tag\*(C'\fR and conform to its interface. See Log::Agent::Tag for details. .Sp At runtime, well after the creation of the logging object, it may be desirable to add (or remove) a user tag. Use the \f(CW\*(C`tags\*(C'\fR attribute to retrieve the tag list object and interact with it, as explained in Log::Agent::Tag_List. .SS "Logging Interface" .IX Subsection "Logging Interface" Each routine is documented to take a single string, but you may also supply a code reference as the first argument, followed by extra arguments. That routine will be called, along with the extra arguments, to generate the message to be logged. If that sounds crazy, think about the \s-1CPU\s0 time we save by \s-1NOT\s0 calling the routine. If nothing is returned by the routine, nothing is logged. .PP If more than one argument is given, and the first argument is not a code reference, then it is taken as a \fBprintf()\fR format, and the remaining arguments are used to fill the various \*(L"%\*(R" placeholders in the format. The special \*(L"%m\*(R" placeholder does not make use of any extra argument and is replaced by a stringification of the error message contained in $!, aka \f(CW\*(C`errno\*(C'\fR. .PP There is a logging routine defined for each \fBsyslog\fR\|(3) priority, along with aliases for some of them. Here is an exhaustive table, sorted by decreasing priority. .PP .Vb 10 \& Syslog Alias \& \-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\- \& emerg emergency \& alert \& crit critical \& err error \& warning warn \& notice \& info \& debug .Ve .PP We shall document only one routine for a given level: for instance, we document \f(CW\*(C`warn\*(C'\fR but you could also use the standard \f(CW\*(C`warning\*(C'\fR to achieve exactly the same funciton. .ie n .IP """emergency($str)""" 4 .el .IP "\f(CWemergency($str)\fR" 4 .IX Item "emergency($str)" Log at the \*(L"emerg\*(R" level, usually just before panicing. Something terribly bad has been detected, and the program might crash soon after logging this. .ie n .IP """alert($str)""" 4 .el .IP "\f(CWalert($str)\fR" 4 .IX Item "alert($str)" Log at the \*(L"alert\*(R" level, to signal a problem requiring immediate attention. Usually, some functionality will be missing until the condition is fixed. .ie n .IP """critical($str)""" 4 .el .IP "\f(CWcritical($str)\fR" 4 .IX Item "critical($str)" Log at the \*(L"crit\*(R" level, to signal a severe error that prevents fulfilling some activity. .ie n .IP """error($str)""" 4 .el .IP "\f(CWerror($str)\fR" 4 .IX Item "error($str)" Log at the \*(L"err\*(R" level, to signal a regular error. .ie n .IP """warn($str)""" 4 .el .IP "\f(CWwarn($str)\fR" 4 .IX Item "warn($str)" Log at the \*(L"warning\*(R" level, which is an indication that something unusual occurred. .ie n .IP """notice($str)""" 4 .el .IP "\f(CWnotice($str)\fR" 4 .IX Item "notice($str)" Log at the \*(L"notice\*(R" level, indicating something that is fully handled by the applicaiton, but which is not the norm. A significant condition, as they say. .ie n .IP """info($str)""" 4 .el .IP "\f(CWinfo($str)\fR" 4 .IX Item "info($str)" Log at the \*(L"info\*(R" level, for their amusement. .ie n .IP """debug($str)""" 4 .el .IP "\f(CWdebug($str)\fR" 4 .IX Item "debug($str)" Log at the \*(L"debug\*(R" level, to further confuse them. .SS "Closing Channel" .IX Subsection "Closing Channel" .ie n .IP """close""" 4 .el .IP "\f(CWclose\fR" 4 .IX Item "close" This routine closes the channel. Further logging to the logger is permitted, but will be simply discarded without notice. .SS "Attribute Access" .IX Subsection "Attribute Access" The following access routines are defined: .ie n .IP """channel""" 4 .el .IP "\f(CWchannel\fR" 4 .IX Item "channel" The defined logging channel. Cannot be changed. .ie n .IP """max_prio"" and ""max_prio_str""" 4 .el .IP "\f(CWmax_prio\fR and \f(CWmax_prio_str\fR" 4 .IX Item "max_prio and max_prio_str" Returns the maximum priority recorded, either as a numeric value or as a string. For the correspondance between the two, see Log::Agent::Priorities. .ie n .IP """min_prio"" and ""min_prio_str""" 4 .el .IP "\f(CWmin_prio\fR and \f(CWmin_prio_str\fR" 4 .IX Item "min_prio and min_prio_str" Returns the minimum priority recorded, either as a numeric value or as a string. For the correspondance between the two, see Log::Agent::Priorities. .ie n .IP """set_caller_info"" \fIlist\fR" 4 .el .IP "\f(CWset_caller_info\fR \fIlist\fR" 4 .IX Item "set_caller_info list" Dynamically change the caller information formatting in the logs. The \fIlist\fR given supersedes the initial settings done via the \f(CW\*(C`\-caller\*(C'\fR argument, if any, and is passed to the creation routine of the \&\f(CW\*(C`Log::Agent::Tag::Caller\*(C'\fR class. Note that a plain list must be given, not a list ref. An empty list removes caller information from subsequent logs. .Sp Please see Log::Agent::Tag::Caller to get the allowed parameters for \fIlist\fR. .ie n .IP """set_max_prio($prio)"" and ""set_min_prio($prio)""" 4 .el .IP "\f(CWset_max_prio($prio)\fR and \f(CWset_min_prio($prio)\fR" 4 .IX Item "set_max_prio($prio) and set_min_prio($prio)" Used to modify the maximum/minimum priorities. You can use either the string value or the numerical equivalent, as documented in Log::Agent::Priorities. .ie n .IP """set_priority_info"" \fIlist\fR" 4 .el .IP "\f(CWset_priority_info\fR \fIlist\fR" 4 .IX Item "set_priority_info list" Dynamically change the priority information formatting in the logs. The \fIlist\fR given supersedes the initial settings done via the \f(CW\*(C`\-priority\*(C'\fR argument, if any, and is passed to the creation routine of the \&\f(CW\*(C`Log::Agent::Tag::Priority\*(C'\fR class. Note that a plain list must be given, not a list ref. An empty list removes priority information from subsequent logs. .Sp Please see Log::Agent::Tag::Priority to get the allowed parameters for \fIlist\fR. .ie n .IP """tags""" 4 .el .IP "\f(CWtags\fR" 4 .IX Item "tags" Returns a \f(CW\*(C`Log::Agent::Tag_List\*(C'\fR object, which holds all user-defined tags that are to be added to each log message. .Sp The initial list of tags is normally supplied by the application at creation time, via the \f(CW\*(C`\-tags\*(C'\fR argument. See Log::Agent::Tag_List for the operations that can be performed on that object. .SH "AUTHORS" .IX Header "AUTHORS" Raphael Manfredi (Raphael_Manfredi@pobox.com) Mark Rogaski (mrogaski@cpan.org) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBLog::Agent::Channel\fR\|(3).