⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log::message.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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" '''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 turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD.  Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\.    de IX.    tm Index:\\$1\t\\n%\t"\\$2"...    nr % 0.    rr F.\}.el \{\.    de IX...\}.\".\" 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::Message 3".TH Log::Message 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" 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::Message \- A generic message storing mechanism;.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\&    use Log::Message private => 0, config => \*(Aq/our/cf_file\*(Aq;\&\&    my $log = Log::Message\->new(    private => 1,\&                                    level   => \*(Aqlog\*(Aq,\&                                    config  => \*(Aq/my/cf_file\*(Aq,\&                               );\&\&    $log\->store(\*(Aqthis is my first message\*(Aq);\&\&    $log\->store(    message => \*(Aqmessage #2\*(Aq,\&                    tag     => \*(AqMY_TAG\*(Aq,\&                    level   => \*(Aqcarp\*(Aq,\&                    extra   => [\*(Aqthis is an argument to the handler\*(Aq],\&               );\&\&    my @last_five_items = $log\->retrieve(5);\&\&    my @items = $log\->retrieve( tag     => qr/my_tag/i,\&                                message => qr/\ed/,\&                                remove  => 1,\&                              );\&\&    my @items = $log\->final( level => qr/carp/, amount => 2 );\&\&    my $first_error = $log\->first()\&\&    # croak with the last error on the stack\&    $log\->final\->croak;\&\&    # empty the stack\&    $log\->flush();.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"Log::Message is a generic message storage mechanism.It allows you to store messages on a stack \*(-- either shared or private\&\*(-- and assign meta-data to it.Some meta-data will automatically be added for you, like a timestampand a stack trace, but some can be filled in by the user, like a tagby which to identify it or group it, and a level at which to handlethe message (for example, log it, or die with it).PPLog::Message also provides a powerful way of searching through itemsby regexes on messages, tags and level..SH "Hierarchy".IX Header "Hierarchy"There are 4 modules of interest when dealing with the Log::Message::*modules:.IP "Log::Message" 4.IX Item "Log::Message"Log::Message provides a few methods to manipulate the stack it keeps.It has the option of keeping either a private or a public stack.More on this below..IP "Log::Message::Item" 4.IX Item "Log::Message::Item"These are individual message items, which are objects that containthe user message as well as the meta-data described above.See the Log::Message::Item manpage to see how to extract this meta-data and how to work with the Item objects.You should never need to create your own Item objects, but knowingabout their methods and accessors is important if you want to writeyour own handlers. (See below).IP "Log::Message::Handlers" 4.IX Item "Log::Message::Handlers"These are a collection of handlers that will be called for a levelthat is used on a Log::Message::Item object.For example, if a message is logged with the 'carp' level, the 'carp'handler from Log::Message::Handlers will be called.See the Log::Message::Handlers manpage for more explanation about howhandlers work, which one are available and how to create your own..IP "Log::Message::Config" 4.IX Item "Log::Message::Config"Per Log::Message object, there is a configuration required that willfill in defaults if the user did not specify arguments to overridethem (like for example what tag will be set if none was provided),Log::Message::Config handles the creation of these configurations..SpConfiguration can be specified in 4 ways:.RS 4.IP "\(bu" 4As a configuration file when you \f(CW\*(C`use Log::Message\*(C'\fR.IP "\(bu" 4As arguments when you \f(CW\*(C`use Log::Message\*(C'\fR.IP "\(bu" 4As a configuration file when you create a new Log::Message object.(The config will then only apply to that object if you marked it asprivate).IP "\(bu" 4As arguments when you create a new Log::Message object..SpYou should never need to use the Log::Message::Config module yourself,as this is transparently done by Log::Message, but its manpage doesprovide an explanation of how you can create a config file..RE.RS 4.RE.SH "Options".IX Header "Options"When using Log::Message, or creating a new Log::Message object, you cansupply various options to alter its behaviour.Of course, there are sensible defaults should you choose to omit theseoptions..PPBelow an explanation of all the options and how they work..IP "config" 4.IX Item "config"The path to a configuration file to be read.See the manpage of Log::Message::Config for the required format.SpThese options will be overridden by any explicit arguments passed..IP "private" 4.IX Item "private"Whether to create, by default, private or shared objects.If you choose to create shared objects, all Log::Message objects willuse the same stack..SpThis means that even though every module may make its own \f(CW$log\fR objectthey will still be sharing the same error stack on which they areputting errors and from which they are retrieving..SpThis can be useful in big projects..SpIf you choose to create a private object, then the stack will ofcourse be private to this object, but it will still fall back to theshared config should no private config or overriding arguments beprovided..IP "verbose" 4.IX Item "verbose"Log::Message makes use of another module to validate its arguments,which is called Params::Check, which is a lightweight, yet powerful input checker and parser. (See the Params::Check manpage for details)..SpThe verbose setting will control whether this module willgenerate warnings if something improper is passed as input, or merelysilently returns undef, at which point Log::Message will generate awarning..SpIt's best to just leave this at its default value, which is '1'.IP "tag" 4.IX Item "tag"The tag to add to messages if none was provided. If neither yourconfig, nor any specific arguments supply a tag, then Log::Message willset it to '\s-1NONE\s0'.SpTags are useful for searching on or grouping by. For example, youcould tag all the messages you want to go to the user as '\s-1USER\s0 \s-1ERROR\s0'and all those that are only debug information with '\s-1DEBUG\s0'..SpAt the end of your program, you could then print all the ones tagged\&'\s-1USER\s0 \s-1ERROR\s0' to \s-1STDOUT\s0, and those marked '\s-1DEBUG\s0' to a log file..IP "level" 4.IX Item "level"\&\f(CW\*(C`level\*(C'\fR describes what action to take when a message is logged. Justlike \f(CW\*(C`tag\*(C'\fR, Log::Message will provide a default (which is 'log') ifneither your config file, nor any explicit arguments are given tooverride it..SpSee the Log::Message::Handlers manpage to see what handlers areavailable by default and what they do, as well as to how to add yourown handlers..IP "remove" 4.IX Item "remove"This indicates whether or not to automatically remove the messagesfrom the stack when you've retrieved them.The default setting provided by Log::Message is '0': do not remove..IP "chrono" 4.IX Item "chrono"This indicates whether messages should always be fetched inchronological order or not.This simply means that you can choose whether, when retrieving items,the item most recently added should be returned first, or the one thathad been added most long ago..SpThe default is to return the newest ones first.SH "Methods".IX Header "Methods".Sh "new".IX Subsection "new"This creates a new Log::Message object; The parameters it takes aredescribed in the \f(CW\*(C`Options\*(C'\fR section below and let it just be repeatedthat you can use these options like this:.PP.Vb 1\&    my $log = Log::Message\->new( %options );.Ve.PPas well as during \f(CW\*(C`use\*(C'\fR time, like this:.PP.Vb 1\&    use Log::Message option1 => value, option2 => value.Ve.PPThere are but 3 rules to keep in mind:.IP "\(bu" 4Provided arguments take precedence over a configuration file..IP "\(bu" 4Arguments to new take precedence over options provided at \f(CW\*(C`use\*(C'\fR time.IP "\(bu" 4An object marked private will always have an empty stack to begin with.Sh "store".IX Subsection "store"This will create a new Item object and store it on the stack..PPPossible arguments you can give to it are:.IP "message" 4.IX Item "message"This is the only argument that is required. If no other argumentsare given, you may even leave off the \f(CW\*(C`message\*(C'\fR key. The argumentwill then automatically be assumed to be the message..IP "tag" 4.IX Item "tag"The tag to add to this message. If not provided, Log::Message will lookin your configuration for one..IP "level" 4.IX Item "level"The level at which this message should be handled. If not provided,Log::Message will look in your configuration for one..IP "extra" 4.IX Item "extra"This is an array ref with arguments passed to the handler for thismessage, when it is called from \fIstore()\fR;.SpThe handler will receive them as a normal list.PP\&\fIstore()\fR will return true upon success and undef upon failure, as wellas issue a warning as to why it failed..Sh "retrieve".IX Subsection "retrieve"This will retrieve all message items matching the criteria specifiedfrom the stack..PPHere are the criteria you can discriminate on:.IP "tag" 4.IX Item "tag"A regex to which the tag must adhere. For example \f(CW\*(C`qr/\ew/\*(C'\fR..IP "level" 4.IX Item "level"A regex to which the level must adhere..IP "message" 4.IX Item "message"A regex to which the message must adhere..IP "amount" 4.IX Item "amount"Maximum amount of errors to return.IP "chrono" 4.IX Item "chrono"Return in chronological order, or not?.IP "remove" 4.IX Item "remove"Remove items from the stack upon retrieval?.PPIn scalar context it will return the first item matching your criteriaand in list context, it will return all of them..PPIf an error occurs while retrieving, a warning will be issued andundef will be returned..Sh "first".IX Subsection "first"This is a shortcut for retrieving the first item(s) stored on thestack. It will default to only retrieving one if called with noarguments, and will always return results in chronological order..PPIf you only supply one argument, it is assumed to be the amount youwish returned..PPFurthermore, it can take the same arguments as \f(CW\*(C`retrieve\*(C'\fR can..Sh "last".IX Subsection "last"This is a shortcut for retrieving the last item(s) stored on thestack. It will default to only retrieving one if called with noarguments, and will always return results in reverse chronologicalorder..PPIf you only supply one argument, it is assumed to be the amount youwish returned..PPFurthermore, it can take the same arguments as \f(CW\*(C`retrieve\*(C'\fR can..Sh "flush".IX Subsection "flush"This removes all items from the stack and returns them to the caller.SH "SEE ALSO".IX Header "SEE ALSO"Log::Message::Item, Log::Message::Handlers, Log::Message::Config.SH "AUTHOR".IX Header "AUTHOR"This module byJos Boumans <kane@cpan.org>..SH "Acknowledgements".IX Header "Acknowledgements"Thanks to Ann Barcomb for her suggestions..SH "COPYRIGHT".IX Header "COPYRIGHT"This module iscopyright (c) 2002 Jos Boumans <kane@cpan.org>.All rights reserved..PPThis library is free software;you may redistribute and/or modify it under the sameterms as Perl itself.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -