[telepathy-butterfly/master] Implemented Telepathy debug interface using python logging module

Louis-Francis Ratté-Boulianne louis-francis.ratte-boulianne at collabora.co.uk
Mon Aug 10 12:38:36 PDT 2009


---
 butterfly/__init__.py |    1 +
 butterfly/debug.py    |   37 +++++++++++++++++++++++++++++++++++++
 telepathy-butterfly   |    2 ++
 3 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 butterfly/debug.py

diff --git a/butterfly/__init__.py b/butterfly/__init__.py
index bc379df..bd77592 100644
--- a/butterfly/__init__.py
+++ b/butterfly/__init__.py
@@ -17,3 +17,4 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from connection_manager import *
+from debug import *
diff --git a/butterfly/debug.py b/butterfly/debug.py
new file mode 100644
index 0000000..6371f64
--- /dev/null
+++ b/butterfly/debug.py
@@ -0,0 +1,37 @@
+# telepathy-butterfly - an MSN connection manager for Telepathy
+#
+# Copyright (C) 2009 Collabora Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+import telepathy
+
+class ButterflyDebug(telepathy.server.Debug):
+    """Butterfly debug interface
+
+    Implements the org.freedesktop.Telepathy.Debug interface"""
+
+    def __init__(self, conn_manager):
+        telepathy.server.Debug.__init__(self, conn_manager)
+
+    def get_record_name(self, record):
+        name = record.name
+        if name.startswith("Butterfly."):
+            domain, category = name.split('.', 1)
+        else:
+            domain = "papyon"
+            category = name
+        name = domain.lower() + "/" + category.lower()
+        return name
diff --git a/telepathy-butterfly b/telepathy-butterfly
index 32dc3a3..667a1c7 100755
--- a/telepathy-butterfly
+++ b/telepathy-butterfly
@@ -46,6 +46,7 @@ debug_divert_messages(os.getenv('BUTTERFLY_LOGFILE'))
 logging.basicConfig(level=logging.DEBUG)
 
 from butterfly import ButterflyConnectionManager
+from butterfly import ButterflyDebug
 from butterfly.util.decorator import async
 
 logger = logging.getLogger('Butterfly')
@@ -81,6 +82,7 @@ if __name__ == '__main__':
 
     try:
         manager = ButterflyConnectionManager(shutdown_func=shutdown_callback)
+        handler = ButterflyDebug(manager)
     except dbus.exceptions.NameExistsException:
         logger.warning('Failed to acquire bus name, connection manager already running?')
         sys.exit(1)
-- 
1.5.6.5



More information about the telepathy-commits mailing list