On Jan 24, 2011, at 1:18 PM, Jason J. W. Williams wrote:

> In my opinion this has been a problem for a very long time, and it
> would be better to have a correction that fits the majority of cases
> with a small code change now rather than wait for the perfect log
> system. These changes don't preclude a better logger and way of
> filtering these out in the future. self.noisy may be viewed as a hack,
> but honestly it's worked well for me and it's easy to understand what
> it does.
> 
> If the compromise is the 4021 patch (wrapping with "if self.noisy"),
> with noisy defaulting to True, I think that's a good solution today
> without precluding the perfect solution when someone wants to build
> it.

While I agree with the general sentiment (incremental improvements that can be 
done now are pretty much always better than gigantic overhauls that have to be 
put off until later) the current logging system is already pretty much designed 
for this, we're just not using it right.  Trimming JP's message a bit to just 
the key part:

>> This doesn't even have to mean changes to LogPublisher.  It could mean 
>> replacing:
>> 
>>  log.msg("%s starting on %s"%(self.protocol.__class__,
>> self._realPortNumber))
>> 
>> with:
>> 
>>  log.msg(
>>     event_source=self,
>>     event_type="start",
>>     protocol=self.protocol,
>>     port_number=self._realPortNumber)
>> 
>> (and documenting and testing).  It may well be nice to have LogPublisher be
>> able to dispatch these more efficiently, but that's just an optimization.


That is _literally_ all that needs to be done to preserve the functionality JP 
likes.  You don't have to change the implementation of log.msg: it already 
accepts **kw, specifically for this reason.  A message logged in this manner 
(with no "message" or "format" event key) will produce no text output in the 
log.  So the amount of work involved is really just writing one line of code.  
Which JP already wrote, here.  It just needs a unit test and a review :).

I do wonder why he went with the PEP8-style underscore parameter names rather 
than Twisted-style intercapped names though :).

-glyph

P.S.: In the future, please reply inline, it's standard etiquette for this list.


_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to