Re: [Repoze-dev] debug logger evilness?

2010-08-06 Thread Chris McDonough
On Fri, 2010-08-06 at 17:49 +0100, Chris Withers wrote:
> Chris McDonough wrote:
> > Calling getLogger results in an *atexit* hook related to a handler being
> > registered for the current Python process.  It might also, depending on
> > its mood, print to stdout.  These things make it miserable to actually
> > unit test any application which calls getLogger.  See also
> > http://plope.com/Members/chrism/logging_blues 
> 
> You want LogCapture:
> http://packages.python.org/testfixtures/logging.html

That looks useful for things that do use getLogger and for people who
have problems mocking up loggers.  But FIWW, I don't really have a
problem mocking up the debug logger in the BFG unit tests and I can't
think up a case where I want to assert anything about what gets sent to
it except in its own unit tests.

> Admittedly, I hadn't noticed the atexit hook getting added, but I've 
> never been bitten by it..

I have.  It hurt bad.  See this scar above my eye on my forehead?
...

- C

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] debug logger evilness?

2010-08-06 Thread Chris Withers
Chris McDonough wrote:
> Calling getLogger results in an *atexit* hook related to a handler being
> registered for the current Python process.  It might also, depending on
> its mood, print to stdout.  These things make it miserable to actually
> unit test any application which calls getLogger.  See also
> http://plope.com/Members/chrism/logging_blues 

You want LogCapture:
http://packages.python.org/testfixtures/logging.html

Admittedly, I hadn't noticed the atexit hook getting added, but I've 
never been bitten by it..

> That said, you can pass in a logger instance to the Configurator as a
> debug logger (as the debug_logger parameter) if you need to replace it
> to capture logging output of BFG itself during a "unit test" (more
> likely a functional test really).

Yep, certainly functional tests...

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
 - http://www.simplistix.co.uk
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] debug logger evilness?

2010-08-06 Thread Chris McDonough
Calling getLogger results in an *atexit* hook related to a handler being
registered for the current Python process.  It might also, depending on
its mood, print to stdout.  These things make it miserable to actually
unit test any application which calls getLogger.  See also
http://plope.com/Members/chrism/logging_blues 

That said, you can pass in a logger instance to the Configurator as a
debug logger (as the debug_logger parameter) if you need to replace it
to capture logging output of BFG itself during a "unit test" (more
likely a functional test really).

If you're currently using the debug logger for your own application, and
that's why you need to replace it within a unit test, maybe just don't
use it.  Just use getLogger and accept its evilness or construct your
own logger instance by hand.  No object within repoze.bfg.log is an API.
The debug logger is meant for internal use by BFG only.

On Fri, 2010-08-06 at 17:22 +0100, Chris Withers wrote:
> Hi All,
> 
> Is there any reason why repoze.bfg.log:make_stream_logger manually 
> instantiates a logger rather than doing logging.getLogger(name)?
> 
> It makes it harder than it needs to be to replace the handlers of the 
> logger for unit testing purposes :-/
> 
> cheers,
> 
> Chris
> 
> ___
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev
> 


___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] debug logger evilness?

2010-08-06 Thread Chris Withers
Hi All,

Is there any reason why repoze.bfg.log:make_stream_logger manually 
instantiates a logger rather than doing logging.getLogger(name)?

It makes it harder than it needs to be to replace the handlers of the 
logger for unit testing purposes :-/

cheers,

Chris

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev