™.. Log::Message - Online Linux Manual PageSection : 3pm
Updated : 2009-02-25
Source : perl v5.10.1
Note : Perl Programmers Reference Guide
NAMELog::Message − A generic message storing mechanism;
SYNOPSIS use Log::Message private => 0, config => '/our/cf_file';
my $log = Log::Message−>new( private => 1,
level => 'log',
config => '/my/cf_file',
);
$log−>store('this is my first message');
$log−>store( message => 'message #2',
tag => 'MY_TAG',
level => 'carp',
extra => ['this is an argument to the handler'],
);
my @last_five_items = $log−>retrieve(5);
my @items = $log−>retrieve( tag => qr/my_tag/i,
message => qr/\d/,
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();
DESCRIPTIONLog::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 timestamp and a stack trace, but some can be filled in by the user, like a tag by which to identify it or group it, and a level at which to handle the message (for example, log it, or die with it) Log::Message also provides a powerful way of searching through items by regexes on messages, tags and level.
HierarchyThere are 4 modules of interest when dealing with the Log::Message::* modules: 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. Log::Message::Item These are individual message items, which are objects that contain the 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 knowing about their methods and accessors is important if you want to write your own handlers. (See below) Log::Message::Handlers These are a collection of handlers that will be called for a level that 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 how handlers work, which one are available and how to create your own. Log::Message::Config Per Log::Message object, there is a configuration required that will fill in defaults if the user did not specify arguments to override them (like for example what tag will be set if none was provided), Log::Message::Config handles the creation of these configurations. Configuration can be specified in 4 ways: • As a configuration file when you \*(C`use Log::Message\*(C'\fR • As arguments when you \*(C`use Log::Message\*(C'\fR • As a configuration file when you create a new Log::Message object. (The config will then only apply to that object if you marked it as private) • As arguments when you create a new Log::Message object. You should never need to use the Log::Message::Config module yourself, as this is transparently done by Log::Message, but its manpage does provide an explanation of how you can create a config file.
OptionsWhen using Log::Message, or creating a new Log::Message object, you can supply various options to alter its behaviour. Of course, there are sensible defaults should you choose to omit these options. Below an explanation of all the options and how they work. config The path to a configuration file to be read. See the manpage of Log::Message::Config for the required format These options will be overridden by any explicit arguments passed. private Whether to create, by default, private or shared objects. If you choose to create shared objects, all Log::Message objects will use the same stack. This means that even though every module may make its own $log object they will still be sharing the same error stack on which they are putting errors and from which they are retrieving. This can be useful in big projects. If you choose to create a private object, then the stack will of course be private to this object, but it will still fall back to the shared config should no private config or overriding arguments be provided. 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). The verbose setting will control whether this module will generate warnings if something improper is passed as input, or merely silently returns undef, at which point Log::Message will generate a warning. It's best to just leave this at its default value, which is '1' tag The tag to add to messages if none was provided. If neither your config, nor any specific arguments supply a tag, then Log::Message will set it to 'NONE' Tags are useful for searching on or grouping by. For example, you could tag all the messages you want to go to the user as 'USER ERROR' and all those that are only debug information with 'DEBUG'. At the end of your program, you could then print all the ones tagged 'USER ERROR' to STDOUT, and those marked 'DEBUG' to a log file. level \*(C`level\*(C'\fR describes what action to take when a message is logged. Just like \*(C`tag\*(C'\fR, Log::Message will provide a default (which is 'log') if neither your config file, nor any explicit arguments are given to override it. See the Log::Message::Handlers manpage to see what handlers are available by default and what they do, as well as to how to add your own handlers. remove This indicates whether or not to automatically remove the messages from the stack when you've retrieved them. The default setting provided by Log::Message is '0': do not remove. chrono This indicates whether messages should always be fetched in chronological 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 that had been added most long ago. The default is to return the newest ones first
Methods
newThis creates a new Log::Message object; The parameters it takes are described in the \*(C`Options\*(C'\fR section below and let it just be repeated that you can use these options like this: my $log = Log::Message−>new( %options );
as well as during \*(C`use\*(C'\fR time, like this: use Log::Message option1 => value, option2 => value
There are but 3 rules to keep in mind: • Provided arguments take precedence over a configuration file. • Arguments to new take precedence over options provided at \*(C`use\*(C'\fR time • An object marked private will always have an empty stack to begin with
storeThis will create a new Item object and store it on the stack. Possible arguments you can give to it are: message This is the only argument that is required. If no other arguments are given, you may even leave off the \*(C`message\*(C'\fR key. The argument will then automatically be assumed to be the message. tag The tag to add to this message. If not provided, Log::Message will look in your configuration for one. level The level at which this message should be handled. If not provided, Log::Message will look in your configuration for one. extra This is an array ref with arguments passed to the handler for this message, when it is called from store(); The handler will receive them as a normal list store() will return true upon success and undef upon failure, as well as issue a warning as to why it failed.
retrieveThis will retrieve all message items matching the criteria specified from the stack. Here are the criteria you can discriminate on: tag A regex to which the tag must adhere. For example \*(C`qr/\ew/\*(C'\fR. level A regex to which the level must adhere. message A regex to which the message must adhere. amount Maximum amount of errors to return chrono Return in chronological order, or not? remove Remove items from the stack upon retrieval? In scalar context it will return the first item matching your criteria and in list context, it will return all of them. If an error occurs while retrieving, a warning will be issued and undef will be returned.
firstThis is a shortcut for retrieving the first item(s) stored on the stack. It will default to only retrieving one if called with no arguments, and will always return results in chronological order. If you only supply one argument, it is assumed to be the amount you wish returned. Furthermore, it can take the same arguments as \*(C`retrieve\*(C'\fR can.
lastThis is a shortcut for retrieving the last item(s) stored on the stack. It will default to only retrieving one if called with no arguments, and will always return results in reverse chronological order. If you only supply one argument, it is assumed to be the amount you wish returned. Furthermore, it can take the same arguments as \*(C`retrieve\*(C'\fR can.
flushThis removes all items from the stack and returns them to the caller
SEE ALSOLog::Message::Item, Log::Message::Handlers, Log::Message::Config
AUTHORThis module by Jos Boumans <kane@cpan.org>.
AcknowledgementsThanks to Ann Barcomb for her suggestions.
COPYRIGHTThis module is copyright (c) 2002 Jos Boumans <kane@cpan.org>. All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. 0
Johanes Gumabo
Data Size : 27,241 byte
man-Log::Message.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 192,432
Visitor ID : :
Visitor IP : 3.135.215.149 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Log::Message.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Log::Message.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Log::Message.3pm|41|br══─}─══|'br══─}─══
) (htmlprn|149|Log::Message.3pm|41|'br══─}─══ |'br══─}─══
) (rof_nr_x|149|Log::Message.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (rof_unit_scale_px|41|Log::Message.3pm|51/52|F|.ie \nF ══─{─══. de IX
) (rof_if|19|Log::Message.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (htmlprn|149|Log::Message.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX
) (rof_escape_sequence|91|Log::Message.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2"
) (parse_manual_page_|249|Log::Message.3pm|57|══─}─══|.══─}─══
) (htmlprn|149|Log::Message.3pm|57|.══─}─══ |.══─}─══
) (rof_escape_sequence|91|Log::Message.3pm|172|\*(-- either shared or private |It allows you to store messages on a stack \*(-- either shared or private
) (rof_escape_sequence|91|Log::Message.3pm|173|\*(-- and assign meta-data to it. |\&\*(-- and assign meta-data to it.
) (rof_escape_sequence|91|Log::Message.3pm|217|\*(C`use Log::Message\*(C'\fR |As a configuration file when you \f(CW\*(C`use Log::Message\*(C'\fR
) (rof_escape_sequence|91|Log::Message.3pm|219|\*(C`use Log::Message\*(C'\fR |As arguments when you \f(CW\*(C`use Log::Message\*(C'\fR
) (rof_escape_sequence|91|Log::Message.3pm|290|\*(C`level\*(C'\fR describes what action to take when a message is logged. Just |\&\f(CW\*(C`level\*(C'\fR describes what action to take when a message is logged. Just
) (rof_escape_sequence|91|Log::Message.3pm|291|\*(C`tag\*(C'\fR, Log::Message will provide a default (which is 'log') if |like \f(CW\*(C`tag\*(C'\fR, Log::Message will provide a default (which is 'log') if
) (rof_escape_sequence|91|Log::Message.3pm|317|\*(C`Options\*(C'\fR section below and let it just be repeated |described in the \f(CW\*(C`Options\*(C'\fR section below and let it just be repeated
) (rof_escape_sequence|91|Log::Message.3pm|324|\*(C`use\*(C'\fR time, like this: |as well as during \f(CW\*(C`use\*(C'\fR time, like this:
) (rof_escape_sequence|91|Log::Message.3pm|334|\*(C`use\*(C'\fR time |Arguments to new take precedence over options provided at \f(CW\*(C`use\*(C'\fR time
) (rof_escape_sequence|91|Log::Message.3pm|345|\*(C`message\*(C'\fR key. The argument |are given, you may even leave off the \f(CW\*(C`message\*(C'\fR key. The argument
) (rof_escape_sequence|91|Log::Message.3pm|372|\*(C`qr/\ew/\*(C'\fR. |A regex to which the tag must adhere. For example \f(CW\*(C`qr/\ew/\*(C'\fR.
) (rof_escape_sequence|91|Log::Message.3pm|403|\*(C`retrieve\*(C'\fR can. |Furthermore, it can take the same arguments as \f(CW\*(C`retrieve\*(C'\fR can.
) (rof_escape_sequence|91|Log::Message.3pm|414|\*(C`retrieve\*(C'\fR can. |Furthermore, it can take the same arguments as \f(CW\*(C`retrieve\*(C'\fR can.
)