[Catalyst] Should CATALYST_DEBUG suppress manual calls to
$c->log->debug()?
Jonathan Swartz
swartz at pobox.com
Mon Aug 27 13:38:26 GMT 2007
On Aug 25, 2007, at 3:17 PM, Matt S Trout wrote:
> On Fri, Aug 24, 2007 at 10:15:37PM +0100, Will Hawes wrote:
>> I've been trying unsuccessfully to disable all debug messages
>> while running
>> tests on my app with prove. Setting CATALYST_DEBUG=0 eliminates
>> all the test
>> server debug output such as the list of loaded actions, but i am
>> still
>> seeing the output of every call made to $c->log->debug by my
>> controller
>> code.
>>
>> As far as I can see the docs regarding CATALYST_DEBUG=0 don't make
>> any
>> distinction about where debug messages originate, only that they are
>> suppressed, which presumably means I shouldn't be seeing any debug
>> output at
>> all.
>>
>> Is my mistake in misunderstanding how $c->log->debug() is supposed
>> to work?
>
> Yes.
>
> That logs a message of level 'debug'.
>
> The internal Catalyst debugging aid stuff checks $c->debug and if
> so logs
> messages with the debug level. But that doesn't mean turning off
> the internal
> debugging changes the configuration of your logger whatsoever.
>
But what's the point of using $c->debug to gate debug messages when
you could just check $log->is_debug? It is confusing to have some
debug log messages in the system gated on $c->debug, and others just
on $log->is_debug.
The advantage of $log->is_debug is that some logging systems (e.g.
Log4perl) will allow you to switch debugging on and off at runtime,
without a server restart, even in production.
Jonathan suggests that it might be for performance, but method calls
like $c->debug cannot be optimized away at compile time. And in any
case, the performance gains would be pretty small potatoes.
Jon
More information about the Catalyst
mailing list