#4566 NORM Never A: Bring back categories in sugar.logger

Zarro Boogs per Child bugtracker at laptop.org
Wed Oct 31 12:47:00 EDT 2007


#4566: Bring back categories in sugar.logger
-------------------------+--------------------------------------------------
 Reporter:  smcv         |       Owner:  marco         
     Type:  enhancement  |      Status:  new           
 Priority:  normal       |   Milestone:  Never Assigned
Component:  sugar        |     Version:                
 Keywords:               |    Verified:  0             
-------------------------+--------------------------------------------------
 The Python logging framework allows categories (the argument to
 logging.getLogger()) to be associated with messages. This lets you do
 elaborate filtering (which we don't use), but also lets you see where a
 particular message came from.

 My previous patches to sugar.logger included the category in all messages
 that came through the logging framework, but the refactoring and
 simplification of sugar.logger has caused this to get lost.

 Proposed patch:

 {{{
 --- a/sugar/logger.py
 +++ b/sugar/logger.py
 @@ -39,7 +39,7 @@ def set_level(level):

  def start(log_filename=None):
      logging.basicConfig(level=logging.WARNING,
 -                        format="%(created)f %(levelname)s %(message)s")
 +            format="%(created)f %(levelname)s %(name)s: %(message)s")

      if os.environ.has_key('SUGAR_LOGGER_LEVEL'):
          set_level(os.environ['SUGAR_LOGGER_LEVEL'])
 }}}

 Sample output (the part between DEBUG and ":" is new):

 {{{
 1193849042.438601 DEBUG read-activity: Starting Read...
 1193849042.661859 DEBUG sugar.presence.presenceservice: Creating proxy for
 /org/laptop/Sugar/Presence/Activities/3
 1193849042.667115 DEBUG sugar.presence.activity: <proxy for
 /org/laptop/Sugar/Presence/Activities/3 at 8723acc>: Blocking on
 GetProperties() because someone wants property id
 1193849042.667425 DEBUG sugar.presence.activity: <proxy for
 /org/laptop/Sugar/Presence/Activities/3 at 8723acc>: initial GetProperties
 returned
 1193849042.667565 DEBUG sugar.presence.activity: <proxy for
 /org/laptop/Sugar/Presence/Activities/3 at 8723acc>: Activity properties
 changed to dbus.Dictionary({dbus.UTF8String('name'): dbus.UTF8String('Font
 sizes', variant_level=1), dbus.UTF8String('tags'): dbus.UTF8String('',
 variant_level=1), dbus.UTF8String('color'):
 dbus.UTF8String('#5E008C,#AC32FF', variant_level=1),
 dbus.UTF8String('private'): dbus.Boolean(False, variant_level=1),
 dbus.UTF8String('type'): dbus.UTF8String('org.laptop.Chat',
 variant_level=1), dbus.UTF8String('id'):
 dbus.UTF8String('a8aeb32a9ae4926fbf64c9f1edffb52f01c168e8',
 variant_level=1)}, signature=dbus.Signature('sv'))
 }}}

 Code that uses the shortcut functions logging.debug() etc. rather than a
 Logger instance will appear as category "root".

 The conventional category name for library modules is the full name of the
 module, e.g. sugar.presence.presenceservice.

-- 
Ticket URL: <https://dev.laptop.org/ticket/4566>
One Laptop Per Child <https://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list