You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2014/10/15 02:01:38 UTC

git commit: Disable requests http connection logging.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 89e4313f1 -> 72fed752f


Disable requests http connection logging.

Bugs closed: AURORA-770

Reviewed at https://reviews.apache.org/r/26424/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/72fed752
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/72fed752
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/72fed752

Branch: refs/heads/master
Commit: 72fed752fcdbacf0f29e7eaef56c177f5ec9fcf0
Parents: 89e4313
Author: Joshua Cohen <jc...@twopensource.com>
Authored: Tue Oct 14 16:32:03 2014 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Tue Oct 14 16:32:03 2014 -0700

----------------------------------------------------------------------
 src/main/python/apache/aurora/common/transport.py      |  4 ++++
 src/test/python/apache/aurora/common/test_transport.py | 11 +++++++++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/72fed752/src/main/python/apache/aurora/common/transport.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/common/transport.py b/src/main/python/apache/aurora/common/transport.py
index 6f7c355..fbdb1ad 100644
--- a/src/main/python/apache/aurora/common/transport.py
+++ b/src/main/python/apache/aurora/common/transport.py
@@ -12,6 +12,7 @@
 # limitations under the License.
 #
 
+import logging
 from io import BytesIO
 
 import requests
@@ -60,6 +61,9 @@ class TRequestsTransport(TTransportBase):
     self.__timeout = None
     self.__auth = auth
 
+    # Silence requests logs so we don't get messages for every HTTP connection.
+    logging.getLogger('requests').setLevel(logging.WARNING)
+
   def isOpen(self):
     return self.__session is not None
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/72fed752/src/test/python/apache/aurora/common/test_transport.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/common/test_transport.py b/src/test/python/apache/aurora/common/test_transport.py
index c722eae..e0fef91 100644
--- a/src/test/python/apache/aurora/common/test_transport.py
+++ b/src/test/python/apache/aurora/common/test_transport.py
@@ -12,6 +12,7 @@
 # limitations under the License.
 #
 
+import logging
 from threading import Thread
 
 import mock
@@ -96,3 +97,13 @@ def test_request_any_other_exception():
     assert False, 'Only expected TTransportException, got %s' % e
 
   transport.close()
+
+
+def test_requests_transports_lowers_logging_level():
+  logging.getLogger('requests').setLevel(logging.NOTSET)
+
+  TRequestsTransport(
+      'http://localhost:12345',
+      session_factory=lambda: mock.MagicMock(spec=requests.Session))
+
+  assert logging.getLogger('requests').level == logging.WARNING