Bio-Phylo
view release on metacpan or search on metacpan
lib/Bio/Phylo/Util/Logger.pm view on Meta::CPAN
((((A,B),C),D),E);
The example above will write something like the following to the log file:
INFO Bio::Phylo::Forest::Tree::new [Bio/Phylo/Forest/Tree.pm, 99] - constructor called for 'Bio::Phylo::Forest::Tree'
INFO Bio::Phylo::set_name [Bio/Phylo.pm, 281] - setting name 'A'
INFO Bio::Phylo::set_name [Bio/Phylo.pm, 281] - setting name 'B'
INFO Bio::Phylo::set_name [Bio/Phylo.pm, 281] - setting name 'C'
INFO Bio::Phylo::set_name [Bio/Phylo.pm, 281] - setting name 'D'
INFO Bio::Phylo::set_name [Bio/Phylo.pm, 281] - setting name 'E'
=head1 DESCRIPTION
This class defines a logger, a utility object for logging messages.
The other objects in Bio::Phylo use this logger to give detailed feedback
about what they are doing at per-class, per-method, user-configurable log levels
(DEBUG, INFO, WARN, ERROR and FATAL). These log levels are constants that are
optionally exported by this class by passing the ':levels' argument to your
'use' statement, like so:
use Bio::Phylo::Util::Logger ':levels';
If for some reason you don't want this behaviour (i.e. because there is
something else by these same names in your namespace) you must use the fully
qualified names for these levels, i.e. Bio::Phylo::Util::Logger::DEBUG and
so on.
The least verbose is level FATAL, in which case only 'fatal' messages are shown.
The most verbose level, DEBUG, shows debugging messages, including from internal
methods (i.e. ones that start with underscores, and special 'ALLCAPS' perl
methods like DESTROY or TIEARRAY). For example, to monitor what the root class
is doing, you would say:
$logger->( -class => 'Bio::Phylo', -level => DEBUG )
To define global verbosity you can omit the -class argument. To set verbosity
at a more granular level, you can use the -method argument, which takes a
fully qualified method name such as 'Bio::Phylo::set_name', such that messages
originating from within that method's body get a different verbosity level.
=head1 METHODS
=head2 CONSTRUCTOR
=over
=item new()
Constructor for Logger.
Type : Constructor
Title : new
Usage : my $logger = Bio::Phylo::Util::Logger->new;
Function: Instantiates a logger
Returns : a Bio::Phylo::Util::Logger object
Args : -level => Bio::Phylo::Util::Logger::INFO (DEBUG/INFO/WARN/ERROR/FATAL)
-class => a package (or array ref) for which to set verbosity (optional)
-method => a sub name (or array ref) for which to set verbosity (optional)
-file => a file to which to append logging messages
-listeners => array ref of subs that handle logging messages
-prefix => a path fragment to strip from the paths in logging messages
=back
=head2 VERBOSITY LEVELS
=over
=item FATAL
Rarely happens, usually an exception is thrown instead.
=item ERROR
If this happens, something is seriously wrong that needs to be addressed.
=item WARN
If this happens, something is seriously wrong that needs to be addressed.
=item INFO
If something weird is happening, turn up verbosity to this level as it might
explain some of the assumptions the code is making.
=item DEBUG
This is very verbose, probably only useful if you write core Bio::Phylo code.
=back
=head2 LOGGING METHODS
=over
=item debug()
Prints argument debugging message, depending on verbosity.
Type : logging method
Title : debug
Usage : $logger->debug( "debugging message" );
Function: prints debugging message, depending on verbosity
Returns : invocant
Args : logging message
=item info()
Prints argument informational message, depending on verbosity.
Type : logging method
Title : info
Usage : $logger->info( "info message" );
Function: prints info message, depending on verbosity
Returns : invocant
Args : logging message
=item warn()
Prints argument warning message, depending on verbosity.
( run in 2.037 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )