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: 22901
Status: resolved
Priority: 0/
Queue: Log-Dispatch

People
Owner: Nobody in particular
Requestors: MARKSTOS [...] cpan.org
Cc:
AdminCc:

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



Subject: wish: add set_min_level() method
( I may submit a patch for this later as tuits permit ). In a large system it can be useful to have "debug" turned on for one part, but not the whole thing. Therefore, it's useful to be able set a global "min_level" through the constructor, but override that later, at least temporarily. A simple method like set_min_level($level) could do this. It would be neat if there was an option for this declaration to go out of scope and automatically revert to the previous value, but I don't see that feature as required. Mark
Subject: PATCH: wish: add set_min_level() method
From: MARKSTOS [...] cpan.org
On Wed Nov 08 10:21:09 2006, MARKSTOS wrote: Show quoted text
> ( I may submit a patch for this later as tuits permit ). > > In a large system it can be useful to have "debug" turned on for one > part, but not the whole thing. > > Therefore, it's useful to be able set a global "min_level" through the > constructor, but override that later, at least temporarily. > > A simple method like set_min_level($level) could do this.
A patch is attached for this, which includes code, test and doc updates. Mark
diff -rN -u old-Log-Dispatch-2.13/Changes new-Log-Dispatch-2.13/Changes --- old-Log-Dispatch-2.13/Changes 2006-11-14 17:44:45.000000000 -0500 +++ new-Log-Dispatch-2.13/Changes 2006-11-14 17:44:45.000000000 -0500 @@ -1,3 +1,6 @@ +- min_level can now be called after argument creation, to allow temporarily + lowering the logging level for one part of the application. (Mark Stosberg) + 2.13 Sep 25, 2006 - No code changes, just added a SUPPORT section to the docs referring diff -rN -u old-Log-Dispatch-2.13/lib/Log/Dispatch/Output.pm new-Log-Dispatch-2.13/lib/Log/Dispatch/Output.pm --- old-Log-Dispatch-2.13/lib/Log/Dispatch/Output.pm 2006-11-14 17:44:45.000000000 -0500 +++ new-Log-Dispatch-2.13/lib/Log/Dispatch/Output.pm 2006-11-14 17:44:45.000000000 -0500 @@ -90,7 +90,12 @@ sub min_level { - my $self = shift; + my $self = shift; + my $level = shift; + if (defined $level) { + $self->{min_level} = $self->_level_as_number($level); + die "Invalid level specified for min_level" unless defined $self->{min_level}; + } return $self->{level_names}[ $self->{min_level} ]; } @@ -249,8 +254,9 @@ Returns the object's name. -=item * min_level +=item * min_level ($) +If there argument is provided, sets it as the new minimum level. Returns the object's minimum log level. =item * max_level diff -rN -u old-Log-Dispatch-2.13/t/min_level.t new-Log-Dispatch-2.13/t/min_level.t --- old-Log-Dispatch-2.13/t/min_level.t 1969-12-31 19:00:00.000000000 -0500 +++ new-Log-Dispatch-2.13/t/min_level.t 2006-11-14 17:44:45.000000000 -0500 @@ -0,0 +1,17 @@ +use Test::More 'no_plan'; + +use Log::Dispatch; +use Log::Dispatch::Screen; + +my $l = Log::Dispatch::Screen->new( name => 'foo', + min_level => 'warning', stderr => 0 ); + + +is($l->min_level, 'warning', "min_level is set by new"); + +is($l->min_level('debug'), 'debug', "min_level can be set and returned"); + + +is($l->min_level, 'debug', "setting min_level sticks"); + +
Subject: min_level() method (patch not what I thought...)
From: MARKSTOS [...] cpan.org
Hmm, while I successfully added a "min_level()" method to the Log::Dispatch::Output, I really meant to add one to Log::Dispatch. It's less clear to me how to do that in a way that is "clean" within the overall design. I'm going to keep thinking about the best way to solve the case I've run into. Mark
min_level now exists; this ticket should be closed.
On Mon May 14 16:29:32 2012, ETHER wrote: Show quoted text
> min_level now exists; this ticket should be closed.
The request was for a setter. All that exists now is a getter.