summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2010-07-06 13:41:33 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2010-07-09 21:29:06 +0100
commit0f5b5a3d7e7bd773ae7f58f409ccb96e29c491af (patch)
tree49256306188dc7ccedd99c1a462ee010db0dc828
parentc80212d3bf17463525bc5ea5b895a7ffb5a737c1 (diff)
debug: only print to stderr when BUTTERFLY_DEBUG is setdebug
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rwxr-xr-xtelepathy-butterfly17
1 files changed, 17 insertions, 0 deletions
diff --git a/telepathy-butterfly b/telepathy-butterfly
index 246f9d4..553305a 100755
--- a/telepathy-butterfly
+++ b/telepathy-butterfly
@@ -67,6 +67,23 @@ if __name__ == '__main__':
manager.quit()
mainloop.quit()
+ # We only want to log to stderr if BUTTERFLY_DEBUG=all is set, but
+ # we want any other logging handlers to work fine (such as the
+ # debug sender one).
+ if os.environ.get('BUTTERFLY_DEBUG', None) != 'all':
+ # This dummy stream will replace sys.stderr.
+ class DummyStream(object):
+ def write(self, s):
+ pass
+
+ # First, replace the original stderr with our new dummy stream.
+ sys.stderr = DummyStream()
+
+ # The root handler has already had the original stderr set on it,
+ # so let's override that.
+ stderr_handler = logging.root.handlers[0]
+ stderr_handler.stream = sys.stderr
+
if 'BUTTERFLY_PERSIST' not in os.environ:
def timeout_cb():
if len(manager._connections) == 0: