Try to make sugar.presence log messages less misleading (#4027)

This commit is contained in:
Simon McVittie 2007-10-16 17:51:36 +01:00
parent fa55b5af09
commit 48bc73d0c4
4 changed files with 27 additions and 10 deletions

1
NEWS
View File

@ -1,3 +1,4 @@
* #4027 Try to make sugar.presence log messages less misleading (smcv)
* Changed default spacing to 15px (from 8px) (benzea) * Changed default spacing to 15px (from 8px) (benzea)
* Correct the height of the primary palette (benzea) * Correct the height of the primary palette (benzea)
* Use double leading underscores for callback names to avoid name collisions (erikos) * Use double leading underscores for callback names to avoid name collisions (erikos)

View File

@ -322,7 +322,7 @@ class Activity(Window, gtk.Container):
logging.debug("*** Act %s, mesh instance %r, scope %s" % (self._activity_id, mesh_instance, share_scope)) logging.debug("*** Act %s, mesh instance %r, scope %s" % (self._activity_id, mesh_instance, share_scope))
if mesh_instance: if mesh_instance:
# There's already an instance on the mesh, join it # There's already an instance on the mesh, join it
logging.debug("*** Act %s joining existing mesh instance" % self._activity_id) logging.debug("*** Act %s joining existing mesh instance %r", self._activity_id, mesh_instance)
self._shared_activity = mesh_instance self._shared_activity = mesh_instance
self._shared_activity.connect('notify::private', self._shared_activity.connect('notify::private',
self.__privacy_changed_cb) self.__privacy_changed_cb)
@ -537,7 +537,8 @@ class Activity(Window, gtk.Container):
logging.debug('Share of activity %s failed: %s.' % (self._activity_id, err)) logging.debug('Share of activity %s failed: %s.' % (self._activity_id, err))
return return
logging.debug('Share of activity %s successful.' % self._activity_id) logging.debug('Share of activity %s successful, PS activity is %r.',
self._activity_id, activity)
activity.props.name = self._jobject.metadata['title'] activity.props.name = self._jobject.metadata['title']

View File

@ -95,17 +95,21 @@ class Activity(gobject.GObject):
self._handle_to_buddy_path = {} self._handle_to_buddy_path = {}
self._buddy_path_to_handle = {} self._buddy_path_to_handle = {}
def __repr__(self):
return ('<proxy for %s at %x>' % (self._object_path, id(self)))
def _get_properties_reply_cb(self, new_props): def _get_properties_reply_cb(self, new_props):
self._properties_changed_cb(new_props)
self._get_properties_call = None self._get_properties_call = None
_logger.debug('%r: initial GetProperties returned', self)
self._properties_changed_cb(new_props)
def _get_properties_error_cb(self, e): def _get_properties_error_cb(self, e):
self._get_properties_call = None self._get_properties_call = None
# FIXME: do something with the error # FIXME: do something with the error
_logger.warning('Error doing initial GetProperties: %s', e) _logger.warning('%r: Error doing initial GetProperties: %s', self, e)
def _properties_changed_cb(self, new_props): def _properties_changed_cb(self, new_props):
_logger.debug('Activity properties changed to %r', new_props) _logger.debug('%r: Activity properties changed to %r', self, new_props)
val = new_props.get('name', self._name) val = new_props.get('name', self._name)
if isinstance(val, str) and val != self._name: if isinstance(val, str) and val != self._name:
self._name = val self._name = val
@ -137,14 +141,13 @@ class Activity(gobject.GObject):
def do_get_property(self, pspec): def do_get_property(self, pspec):
"""Retrieve a particular property from our property dictionary""" """Retrieve a particular property from our property dictionary"""
_logger.debug('Looking up property %s', pspec.name)
if pspec.name == "joined": if pspec.name == "joined":
return self._joined return self._joined
if self._get_properties_call is not None: if self._get_properties_call is not None:
_logger.debug('Blocking on GetProperties() because someone wants ' _logger.debug('%r: Blocking on GetProperties() because someone '
'property %s', pspec.name) 'wants property %s', self, pspec.name)
self._get_properties_call.block() self._get_properties_call.block()
if pspec.name == "id": if pspec.name == "id":
@ -183,6 +186,8 @@ class Activity(gobject.GObject):
return False return False
def _buddy_handle_joined_cb(self, object_path, handle): def _buddy_handle_joined_cb(self, object_path, handle):
_logger.debug('%r: buddy %s joined with handle %u', self, object_path,
handle)
gobject.idle_add(self._emit_buddy_joined_signal, object_path) gobject.idle_add(self._emit_buddy_joined_signal, object_path)
self._handle_to_buddy_path[handle] = object_path self._handle_to_buddy_path[handle] = object_path
self._buddy_path_to_handle[object_path] = handle self._buddy_path_to_handle[object_path] = handle
@ -196,6 +201,7 @@ class Activity(gobject.GObject):
return False return False
def _buddy_left_cb(self, object_path): def _buddy_left_cb(self, object_path):
_logger.debug('%r: buddy %s left', self, object_path)
gobject.idle_add(self._emit_buddy_left_signal, object_path) gobject.idle_add(self._emit_buddy_left_signal, object_path)
handle = self._buddy_path_to_handle.pop(object_path) handle = self._buddy_path_to_handle.pop(object_path)
self._handle_to_buddy_path.pop(handle, None) self._handle_to_buddy_path.pop(handle, None)
@ -209,11 +215,12 @@ class Activity(gobject.GObject):
return False return False
def _new_channel_cb(self, object_path): def _new_channel_cb(self, object_path):
_logger.debug('%r: new channel created at %s', self, object_path)
gobject.idle_add(self._emit_new_channel_signal, object_path) gobject.idle_add(self._emit_new_channel_signal, object_path)
def get_joined_buddies(self): def get_joined_buddies(self):
"""Retrieve the set of Buddy objects attached to this activity """Retrieve the set of Buddy objects attached to this activity
returns list of presence Buddy objects returns list of presence Buddy objects
""" """
resp = self._activity.GetJoinedBuddies() resp = self._activity.GetJoinedBuddies()
@ -240,7 +247,9 @@ class Activity(gobject.GObject):
The callback will be called with one parameter: None on success, The callback will be called with one parameter: None on success,
or an exception on failure. or an exception on failure.
""" """
self._activity.Invite(buddy.object_path(), message, op = buddy.object_path()
_logger.debug('%r: inviting %s', self, op)
self._activity.Invite(op, message,
reply_handler=lambda: response_cb(None), reply_handler=lambda: response_cb(None),
error_handler=response_cb) error_handler=response_cb)
@ -259,6 +268,7 @@ class Activity(gobject.GObject):
if self._joined: if self._joined:
self.emit("joined", True, None) self.emit("joined", True, None)
return return
_logger.debug('%r: joining', self)
self._activity.Join(reply_handler=self._join_cb, error_handler=self._join_error_cb) self._activity.Join(reply_handler=self._join_cb, error_handler=self._join_error_cb)
def get_channels(self): def get_channels(self):
@ -273,6 +283,8 @@ class Activity(gobject.GObject):
associated with this activity associated with this activity
""" """
(bus_name, connection, channels) = self._activity.GetChannels() (bus_name, connection, channels) = self._activity.GetChannels()
_logger.debug('%r: bus name is %s, connection is %s, channels are %r',
self, bus_name, connection, channels)
return bus_name, connection, channels return bus_name, connection, channels
def _leave_cb(self): def _leave_cb(self):
@ -285,6 +297,7 @@ class Activity(gobject.GObject):
def leave(self): def leave(self):
"""Leave this shared activity""" """Leave this shared activity"""
_logger.debug('%r: leaving', self)
self._joined = False self._joined = False
self._activity.Leave(reply_handler=self._leave_cb, self._activity.Leave(reply_handler=self._leave_cb,
error_handler=self._leave_error_cb) error_handler=self._leave_error_cb)

View File

@ -156,6 +156,7 @@ class PresenceService(gobject.GObject):
returns presence Buddy or Activity representation returns presence Buddy or Activity representation
""" """
_logger.debug('Creating proxy for %s', object_path)
obj = None obj = None
try: try:
obj = self._objcache[object_path] obj = self._objcache[object_path]
@ -174,6 +175,7 @@ class PresenceService(gobject.GObject):
else: else:
raise RuntimeError("Unknown object type") raise RuntimeError("Unknown object type")
self._objcache[object_path] = obj self._objcache[object_path] = obj
_logger.debug('Proxy is %r', obj)
return obj return obj
def _have_object(self, object_path): def _have_object(self, object_path):