diff options
author | Tom Nichols <tmnichols@gmail.com> | 2010-07-01 16:47:08 -0400 |
---|---|---|
committer | Tom Nichols <tmnichols@gmail.com> | 2010-07-01 16:47:08 -0400 |
commit | 065a164223f1cb2df32e438da20b370dc5091578 (patch) | |
tree | 9f4e961fca1fe71a94a443d6e6cb20eafd655d9f /sleekxmpp | |
parent | cd2017b8b0641081f3c61b57882b1b3e775beb2e (diff) | |
download | slixmpp-065a164223f1cb2df32e438da20b370dc5091578.tar.gz slixmpp-065a164223f1cb2df32e438da20b370dc5091578.tar.bz2 slixmpp-065a164223f1cb2df32e438da20b370dc5091578.tar.xz slixmpp-065a164223f1cb2df32e438da20b370dc5091578.zip |
proper logging.
Diffstat (limited to 'sleekxmpp')
-rw-r--r-- | sleekxmpp/xmlstream/statemachine.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sleekxmpp/xmlstream/statemachine.py b/sleekxmpp/xmlstream/statemachine.py index 590abedc..9412d5ad 100644 --- a/sleekxmpp/xmlstream/statemachine.py +++ b/sleekxmpp/xmlstream/statemachine.py @@ -9,6 +9,8 @@ import threading import time import logging +log = logging.getLogger(__name__) + class StateMachine(object): @@ -98,11 +100,11 @@ class StateMachine(object): # indicating that transition should not occur: if not return_val: return return_val - logging.debug(' ==== TRANSITION %s -> %s', self.__current_state, to_state) + log.debug(' ==== TRANSITION %s -> %s', self.__current_state, to_state) self._set_state( to_state ) return return_val # some 'true' value returned by func or True if func was None else: - logging.error( "StateMachine bug!! The lock should ensure this doesn't happen!" ) + log.error( "StateMachine bug!! The lock should ensure this doesn't happen!" ) return False finally: self.notifier.set() @@ -226,24 +228,24 @@ class _StateCtx: while not self.state_machine[ self.from_state ] or not self.state_machine.lock.acquire(False): # detect timeout: if time.time() >= start + self.wait: - logging.debug('StateMachine timeout while waiting for state: %s', self.from_state ) + log.debug('StateMachine timeout while waiting for state: %s', self.from_state ) return False self.state_machine.notifier.wait(self.wait) self._locked = True # lock has been acquired at this point self.state_machine.notifier.clear() - logging.debug('StateMachine entered context in state: %s', + log.debug('StateMachine entered context in state: %s', self.state_machine.current_state() ) return True def __exit__(self, exc_type, exc_val, exc_tb): if exc_val is not None: - logging.exception( "StateMachine exception in context, remaining in state: %s\n%s:%s", + log.exception( "StateMachine exception in context, remaining in state: %s\n%s:%s", self.state_machine.current_state(), exc_type.__name__, exc_val ) if self._locked: if exc_val is None: - logging.debug(' ==== TRANSITION %s -> %s', + log.debug(' ==== TRANSITION %s -> %s', self.state_machine.current_state(), self.to_state) self.state_machine._set_state( self.to_state ) |