[py-dev] py.log suggestion

holger krekel hpk at trillke.net
Sat Oct 15 10:21:41 CEST 2005


On Fri, Oct 14, 2005 at 20:46 -0400, François Pinard wrote:

> 
> I wrote to this list, a little while ago, about using py.log in some big
> Python project I should seriously clean up, and which currently abuses
> of various logging mechanisms.  I thought this job would induce me in
> using quite a flurry of py.log producers.  Instead, for the past weeks,
> I was more active at aggressively forever _removing_ amounts of logging
> calls.  A lot still remain, for which py.log is going to be useful.
> 
> Today, I saw a situation of logging made in context of tracing the
> hearth of one of the evaluation engines.  When such logging/tracing is
> active, the application is going to be applied to a toy subset of the
> real input.  Otherwise, logging would be triggered millions of times.
> The problem is that log messages themselves require a fair amount of
> extra-computation that would better be spared when tracing is not active
> (which is most of the time).
> 
> My suggestion, here, is that producers, besides their ``__call__``
> method, could also offer a ``__nonzero__`` method that would return
> False when the consumer that would apply is None.  So, one could write
> something like:
> 
>     if trace.dossier:
>         diagnostic = prepare_diagnostic_information()
>         trace.dossier(diagnostic)

just a quick note (i am no traavel/sprinting) ... 

yes, thinking about this makes sense.  What about making the tracing 
call callables if they are passed and a consumer is there?  

cheers, 

    holger



More information about the Pytest-dev mailing list