Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Log-Dispatch CPAN distribution.

Report information
The Basics
Id: 4196
Status: resolved
Priority: 0/
Queue: Log-Dispatch

People
Owner: Nobody in particular
Requestors: cubic [...] acronis.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 2.08



Subject: Method which test log level
Sometimes it's better to avoid calculations if loglevel not include desired level. Example: if ($dispatcher->IsLogLevelInclude('info')) { $dispatcher->info(MyHugeCals()); }
From: cubic [...] acronis.com
I did it myself so offer next small patch. [guest - Thu Oct 23 10:11:30 2003]: Show quoted text
> Sometimes it's better to avoid calculations if loglevel not include > desired level. > Example: > if ($dispatcher->IsLogLevelInclude('info')) { > $dispatcher->info(MyHugeCals()); > }
diff -Nru lib.orig/Log/Dispatch.pm lib/Log/Dispatch.pm --- lib.orig/Log/Dispatch.pm 2003-10-23 18:27:20.000000000 +0400 +++ lib/Log/Dispatch.pm 2003-10-23 18:44:34.000000000 +0400 @@ -118,6 +118,17 @@ return $LEVELS{ shift() }; } +sub would_log +{ + my $self = shift; + my $level = shift; + return unless ($self->level_is_valid($level)); + foreach (keys %{$self->{outputs}}) { + return 1 if ($self->{outputs}{$_}->_should_log($level)) + } + return ; +} + __END__ =head1 NAME @@ -202,6 +213,11 @@ Returns true or false to indicate whether or not the given string is a valid log level. Can be called as either a class or object method. +=item * would_log( $string ) + +Returns true or false to indicate whether or not the given string is a +valid log level and would be logged with current list of outputs. + =item * output( $name ) Returns an output of the given name. Returns undef or an empty list,