Reducing debug output
authorEd Page <eopage@byu.net>
Fri, 8 Jan 2010 03:46:15 +0000 (21:46 -0600)
committerEd Page <eopage@byu.net>
Fri, 8 Jan 2010 03:46:15 +0000 (21:46 -0600)
src/channel/text.py
src/channel_manager.py
src/connection.py
src/gvoice/browser_emu.py
src/gvoice/state_machine.py
src/theonering.py

index 2b39833..428f8a7 100644 (file)
@@ -49,13 +49,13 @@ class TextChannel(telepathy.server.ChannelTypeText):
                try:
                        mergedConversations = self._conn.session.voicemails.get_conversation(self._contactKey)
                except KeyError:
-                       _moduleLogger.info("Nothing in the conversation yet for %r" % (self._contactKey, ))
+                       _moduleLogger.debug("Nothing in the conversation yet for %r" % (self._contactKey, ))
                else:
                        self._report_conversation(mergedConversations)
                try:
                        mergedConversations = self._conn.session.texts.get_conversation(self._contactKey)
                except KeyError:
-                       _moduleLogger.info("Nothing in the conversation yet for %r" % (self._contactKey, ))
+                       _moduleLogger.debug("Nothing in the conversation yet for %r" % (self._contactKey, ))
                else:
                        self._report_conversation(mergedConversations)
 
@@ -98,7 +98,7 @@ class TextChannel(telepathy.server.ChannelTypeText):
        def _on_conversations_updated(self, conv, conversationIds):
                if self._contactKey not in conversationIds:
                        return
-               _moduleLogger.info("Incoming messages from %r for existing conversation" % (self._contactKey, ))
+               _moduleLogger.debug("Incoming messages from %r for existing conversation" % (self._contactKey, ))
                mergedConversations = conv.get_conversation(self._contactKey)
                self._report_conversation(mergedConversations)
 
@@ -108,7 +108,7 @@ class TextChannel(telepathy.server.ChannelTypeText):
                newConversations = self._filter_out_read(newConversations)
                newConversations = list(newConversations)
                if not newConversations:
-                       _moduleLogger.info(
+                       _moduleLogger.debug(
                                "New messages for %r have already been read externally" % (self._contactKey, )
                        )
                        return
@@ -121,7 +121,7 @@ class TextChannel(telepathy.server.ChannelTypeText):
                        if newMessage.whoFrom != "Me:"
                ]
                if not newConversations:
-                       _moduleLogger.info(
+                       _moduleLogger.debug(
                                "All incoming messages were really outbound messages for %r" % (self._contactKey, )
                        )
                        return
index 0ea73c2..1f01726 100644 (file)
@@ -24,7 +24,7 @@ class TelepathyChannelManager(object):
                for channel_type in self._requestable_channel_classes:
                        for chan in self._channels[channel_type].values():
                                try:
-                                       _moduleLogger.info("Closing %s %s" % (channel_type, chan._object_path))
+                                       _moduleLogger.debug("Closing %s %s" % (channel_type, chan._object_path))
                                        chan.Close()
                                except Exception:
                                        _moduleLogger.exception("Shutting down %r" % (chan, ))
index 8885232..fe2619b 100644 (file)
@@ -259,7 +259,7 @@ class TheOneRingConnection(
        @gobject_utils.async
        @gtk_toolbox.log_exception(_moduleLogger)
        def _on_conversations_updated(self, conv, conversationIds):
-               _moduleLogger.info("Incoming messages from: %r" % (conversationIds, ))
+               _moduleLogger.debug("Incoming messages from: %r" % (conversationIds, ))
                for contactId, phoneNumber in conversationIds:
                        h = handle.create_handle(self, 'contact', contactId, phoneNumber)
                        # Just let the TextChannel decide whether it should be reported to the user or not
index 1641044..58ecd08 100644 (file)
@@ -94,7 +94,7 @@ class MozillaEmulator(object):
 
                @return: The raw HTML page data
                """
-               _moduleLogger.info("Performing download of %s" % url)
+               _moduleLogger.debug("Performing download of %s" % url)
 
                if extraheaders is None:
                        extraheaders = {}
@@ -116,13 +116,13 @@ class MozillaEmulator(object):
 
                                return self._read(openerdirector, trycount)
                        except urllib2.URLError, e:
-                               _moduleLogger.info("%s: %s" % (e, url))
+                               _moduleLogger.debug("%s: %s" % (e, url))
                                cnt += 1
                                if (-1 < trycount) and (trycount < cnt):
                                        raise
 
                        # Retry :-)
-                       _moduleLogger.info("MozillaEmulator: urllib2.URLError, retrying %d" % cnt)
+                       _moduleLogger.debug("MozillaEmulator: urllib2.URLError, retrying %d" % cnt)
 
        def _build_opener(self, url, postdata = None, extraheaders = None, forbidRedirect = False):
                if extraheaders is None:
index 3f9fcc2..44badca 100644 (file)
@@ -65,16 +65,18 @@ class ConstantStateStrategy(object):
 class GeometricStateStrategy(object):
 
        def __init__(self, init, min, max):
-               assert 0 < init or init == UpdateStateMachine.INFINITE_PERIOD
-               assert 0 < min or min == UpdateStateMachine.INFINITE_PERIOD
+               assert 0 < init and init < max and init != UpdateStateMachine.INFINITE_PERIOD
+               assert 0 < min and min != UpdateStateMachine.INFINITE_PERIOD
                assert min < max or max == UpdateStateMachine.INFINITE_PERIOD
                self._min = min
                self._max = max
                self._init = init
-               self._current = min / 2
+               self._actualInit = init
+               self._current = 0
 
        def initialize_state(self):
                self._current = self._min / 2
+               self._actualInit = self._init - self._min
 
        def increment_state(self):
                if self._max == UpdateStateMachine.INFINITE_PERIOD:
@@ -84,7 +86,7 @@ class GeometricStateStrategy(object):
 
        @property
        def timeout(self):
-               return self._init + self._current
+               return self._actualInit + self._current
 
 
 class StateMachine(object):
@@ -234,8 +236,9 @@ class UpdateStateMachine(StateMachine):
                self._strategy.initialize_state()
                self._schedule_update()
 
+       @gtk_toolbox.log_exception(_moduleLogger)
        def _on_timeout(self):
-               _moduleLogger.info("%s Update" % (self._name))
+               _moduleLogger.debug("%s Update" % (self._name))
                for item in self._updateItems:
                        try:
                                item.update(force=True)
index 08f3175..23ad1ee 100755 (executable)
@@ -97,14 +97,14 @@ def main(logToFile):
                )
        else:
                logging.basicConfig(
-                       level=logging.DEBUG,
+                       level=logging.INFO,
                        format='(%(asctime)s) %(levelname)s:%(name)s:%(message)s',
                        datefmt='%H:%M:%S',
                )
-       logging.info("telepathy-theonering %s-%s" % (constants.__version__, constants.__build__))
-       logging.info("OS: %s" % (os.uname()[0], ))
-       logging.info("Kernel: %s (%s) for %s" % os.uname()[2:])
-       logging.info("Hostname: %s" % os.uname()[1])
+       logging.debug("telepathy-theonering %s-%s" % (constants.__version__, constants.__build__))
+       logging.debug("OS: %s" % (os.uname()[0], ))
+       logging.debug("Kernel: %s (%s) for %s" % os.uname()[2:])
+       logging.debug("Hostname: %s" % os.uname()[1])
 
        persist = 'THEONERING_PERSIST' in os.environ