Mail::Reporter - base-class and error reporter for Mail::Box
| Use Case | Command | Description |
|---|---|---|
| Set log level | $obj->log('ERRORS') | ๐ Change the logging threshold |
| Get current log level | $obj->log | ๐ Returns dualvar (numeric + string) |
| Set trace level | $obj->trace('DEBUG') | ๐จ๏ธ Enable direct warn output |
| Get all errors | $obj->errors | ๐จ Shorthand for report('ERRORS') |
| Get all warnings | $obj->warnings | โ ๏ธ Shorthand for report('WARNINGS') |
| Log a custom message | $obj->log(WARNING => 'msg') | ๐ Store or print a problem |
| Retrieve stored reports | $obj->report('PROGRESS') | ๐ Get messages of a specific level |
| Change global defaults | Mail::Reporter->defaultTrace('NOTICES') | ๐ Set log+ trace level for all new objects |
| Install a callback | Mail::Reporter->defaultTrace($level, \&func) | ๐ All warnings are passed to your function |
| Merge reports from another object | $obj->addReport($other) | ๐ Combine error logs |
| Get all reports from hierarchy | $obj->reportAll | ๐ณ Fetch messages from all maintained objects |
| Convert level string to numeric | Mail::Reporter->logPriority('WARNINGS') | ๐ข Get dualvar for comparisons |
Mail::Reporter is extended by
$folder->log(WARNING => 'go away');
print $folder->trace; # current level
$folder->trace('PROGRESS'); # set level
print $folder->errors;
print $folder->report('PROGRESS');
The Mail::Reporter class is the base class for all classes, except Mail::Message::Field::Fast because it would become slow... This base class is used during initiation of the objects, and for configuring and logging error messages.
The Mail::Reporter class is the base for nearly all other objects. It can store and report problems, and contains the general constructor new().
Mail::Reporter->new(%options) โ This error container is also the base constructor for all modules, (as long as there is no need for another base object) The constructor always accepts the following %options related to error reports.
defaultTrace()."INTERNAL", "ERRORS", "WARNINGS", "PROGRESS", "NOTICES", "DEBUG", and "NONE". The "PROGRESS" level relates to the reading and writing of folders. "NONE" will cause only "INTERNAL" errors to be logged. By the way: "ERROR" is an alias for "ERRORS", as "WARNING" is an alias for "WARNINGS", and "NOTICE" for "NOTICES".warn. The global default for this option can be changed with defaultTrace().$obj->AUTOLOAD() โ ๐ซ By default, produce a nice warning if the sub-classes cannot resolve a method.$obj->addReport($object) โ ๐ Add the report from other $object to the report of this object. This is useful when complex actions use temporary objects which are not returned to the main application but where the main application would like to know about any problems.$obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) / Mail::Reporter->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) โ ๐ Reports the default log and trace level which is used for object as list of two elements. When not explicitly set, both are set to "WARNINGS".$level is set for both loglevel as tracelevel.$callback. The loglevel will be set to NONE, and all warnings produced in your program will get passed to the $callback function. That function will get the problem level, the object or class which reports the problem, and the problem text passed as arguments.๐ Example: setting loglevels
my ($loglevel, $tracelevel) = Mail::Reporter->defaultTrace;
Mail::Reporter->defaultTrace('NOTICES');
my ($l, $t) = Mail::Reporter->defaultTrace('WARNINGS', 'DEBUG');
print $l; # prints "WARNING" (no S!)
print $l+0; # prints "4"
print "Auch" if $l >= $self->logPriority('ERROR');
Mail::Reporter->defaultTrace('NONE'); # silence all reports
$folder->defaultTrace('DEBUG'); # Still set as global default!
$folder->trace('DEBUG'); # local default
๐ Example: installing a callback
Mail::Reporter->defaultTrace
$obj->errors() โ ๐จ Equivalent to $folder->report('ERRORS')$obj->log( [$level, [$strings]] ) / Mail::Reporter->log( [$level, [$strings]] ) โ ๐ As instance method, this function has three different purposes. Without any argument, it returns one scalar containing the number which is internally used to represent the current log level, and the textual representation of the string at the same time. See Scalar::Util method "dualvar" for an explanation.defaultTrace() is used to decide whether the message is shown or ignored.$level and a text string which will be constructed by joining the $strings. If there is no newline, it will be added.๐ Example:
print $message->log; # may print "NOTICE"
print $message->log +0; # may print "3"
$message->log('ERRORS'); # sets a new level, returns the numeric value
$message->log(WARNING => "This message is too large.");
$folder ->log(NOTICE => "Cannot read from file $filename.");
$manager->log(DEBUG => "Hi there!", reverse sort @l);
Mail::Message->log(ERROR => 'Unknown');
$obj->logPriority($level) / Mail::Reporter->logPriority($level) โ ๐ข One error level (log or trace) has more than one representation: a numeric value and one or more strings. For instance, 4, 'WARNING', and 'WARNINGS' are all the same. You can specify any of these, and in return you get a dualvar (see Scalar::Util method "dualvar") back, which contains the number and the singular form."INTERNAL" problems are more important than "NONE".๐ Example:
my $r = Mail::Reporter->logPriority('WARNINGS');
my $r = Mail::Reporter->logPriority('WARNING'); # same
my $r = Mail::Reporter->logPriority(4); # same, deprecated
print $r; # prints 'WARNING' (no S!)
print $r + 0; # prints 4
if($r < Mail::Reporter->logPriority('ERROR')) {..} # true
$obj->logSettings() โ โ๏ธ Returns a list of (key => value) pairs which can be used to initiate a new object with the same log-settings as this one.๐ Example:
$head->new($folder->logSettings);
$obj->notImplemented() โ ๐ A special case of log(), which logs a "INTERNAL" error and then croaks. This is used by extension writers.$obj->report( [$level] ) โ ๐ Get logged reports, as list of strings. If a $level is specified, the log for that level is returned.$level is specified, you get all messages each as reference to a tuple with level and message.๐ Example:
my @warns = $message->report('WARNINGS');
# previous indirectly callable with
my @warns = $msg->warnings;
print $folder->report('ERRORS');
if($folder->report('DEBUG')) {...}
my @reports = $folder->report;
foreach (@reports) {
my ($level, $text) = @$_;
print "$level report: $text";
}
$obj->reportAll( [$level] ) โ ๐ณ Report all messages which were produced by this object and all the objects which are maintained by this object. This will return a list of triplets, each containing a reference to the object which caught the report, the level of the report, and the message.๐ Example:
my $folder = Mail::Box::Manager->new->open(folder => 'inbox');
my @reports = $folder->reportAll;
foreach (@reports) {
my ($object, $level, $text) = @$_;
if($object->isa('Mail::Box')) {
print "Folder $object: $level: $message";
} elsif($object->isa('Mail::Message') {
print "Message ".$object->seqnr.": $level: $message";
}
}
$obj->trace( [$level] ) โ ๐จ๏ธ Change the trace $level of the object. When no arguments are specified, the current level is returned only. It will be returned in one scalar which contains both the number which is internally used to represent the level, and the string which represents it. See logPriority().$obj->warnings() โ โ ๏ธ Equivalent to $folder->report('WARNINGS')$obj->DESTROY() โ ๐๏ธ Cleanup the object.Error: Package $package does not implement $method.
Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package.
This module is part of Mail-Message distribution version 3.012, built on February 11, 2022. Website: http://perl.overmeer.net/CPAN/
Copyrights 2001-2022 by [Mark Overmeer <markov AT cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-21 00:08 @2600:1f28:365:80b0:d8a5:c3c6:bf94:28c0
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format