[Twisted-Python] Log output formatting (was Re: logging question)

Don Dwiggins ddwiggins at advpubtech.com
Fri Dec 2 11:01:11 MST 2011


On 11/30/2011 5:20 AM, exarkun at twistedmatrix.com wrote:
> On 29 Nov, 06:44 pm, ddwiggins at advpubtech.com wrote:
>> Looking at the source of log.py, I'm at a bit of a loss to reconcile 
>> these two forces. Certainly, the two log observers implemented there 
>> use textFromEventDict, but one could create a different observer that 
>> does things entirely differently.
>> The best idea I can come up with is, in the documentation for msg,
>> refer to the documentation for the chosen log observer; then, in each log
>> observer's documentation, describe how the formatting is done, either
>> explicitly, or by reference to textFromEventDict.  (And maybe in the
>> documentation for ILogObserver, recommend strongly that each
>> implementation be explicit about message formatting.)  There should
>> probably also be something in the logging howto.
>>
>> Any better suggestions?
> I'm not sure what you mean by "refer to the documentation for the chosen
> log observer".  The only interpretation I can think of involves changing
> the documentation dynamically at runtime, which doesn't make any sense,
> so I don't think it's what you meant. :)

Sorry, I was being a bit too concise.  What I had in mind was that, when 
you're about to write a call to msg(), you know which log observer 
you're using, so you know which observer's documentation to refer to.

Actually, that might not be quite true; if you use one of the LogFile 
classes, for example, you'd have to infer that it's using 
FileLogObserver, or dig into the source to find out -- again, the kind 
of thing I'd like to avoid.

I'm beginning to think that howto/logging.html is the right place to 
explain things, and needs more work than I originally thought.  I'm 
willing to submit something, but unfortunately not in the very near future.

-- 

Don Dwiggins
Advanced Publishing Technology






More information about the Twisted-Python mailing list