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,