Sunday, May 24, 2009

Logging Framework

I think I've got the Logging stuff set up the way I'd like it to work.

Here's an example (the doc for the responsible class)...

    >>> from loggable import Loggable
>>> Loggable().logfield('test')
2009-05-24 03:23:40,851 - loggable.Loggable - FIELD_CHANGE - test
>>> Loggable().loginfo('test')
2009-05-24 03:24:26,108 - loggable.Loggable - INFO - test
>>> class B(Loggable):
... pass
...
>>> B().loginfo('test')
2009-05-24 03:24:38,306 - __main__.B - INFO - test
>>> B().logpacket('packet XYZ sent')
2009-05-24 03:26:05,299 - __main__.B - PACKET_SENT - packet XYZ sent
>>> B().logresponse('response ABC generated for packet XYZ')
2009-05-24 03:26:15,745 - __main__.B - RESPONSE_GEN - response ABC generated for packet XYZ
>>> B().logfield('field abc123 set to newValue')
2009-05-24 03:26:42,292 - __main__.B - FIELD_CHANGE - field abc123 set to newValue
>>> Loggable().logstate('state changed to CONNECTED')
2009-05-24 03:31:16,848 - loggable.Loggable - STATE_CHANGE - state changed to CONNECTED


Read more...

No comments:

Post a Comment

Followers