Browse Source

HUE-3881 [core] Increase truncation limit of external API responses in DEBUG mode

Jenny Kim 9 years ago
parent
commit
418159a

+ 2 - 2
desktop/core/src/desktop/lib/rest/resource.py

@@ -82,8 +82,8 @@ class Resource(object):
       self._client.logger.debug(
       self._client.logger.debug(
           "%s Got response: %s%s" %
           "%s Got response: %s%s" %
           (method,
           (method,
-           smart_unicode(resp.content[:32], errors='replace'),
-           len(resp.content) > 32 and "..." or ""))
+           smart_unicode(resp.content[:1000], errors='replace'),
+           len(resp.content) > 1000 and "..." or ""))
 
 
     return self._format_response(resp)
     return self._format_response(resp)
 
 

+ 6 - 2
desktop/core/src/desktop/lib/thrift_util.py

@@ -32,6 +32,7 @@ from thrift.transport.TTransport import TBufferedTransport, TFramedTransport, TM
 from thrift.protocol.TBinaryProtocol import TBinaryProtocol
 from thrift.protocol.TBinaryProtocol import TBinaryProtocol
 from thrift.protocol.TMultiplexedProtocol import TMultiplexedProtocol
 from thrift.protocol.TMultiplexedProtocol import TMultiplexedProtocol
 
 
+from django.conf import settings
 from desktop.lib.python_util import create_synchronous_io_multiplexer
 from desktop.lib.python_util import create_synchronous_io_multiplexer
 from desktop.lib.thrift_.http_client import THttpClient
 from desktop.lib.thrift_.http_client import THttpClient
 from desktop.lib.thrift_sasl import TSaslClientTransport
 from desktop.lib.thrift_sasl import TSaslClientTransport
@@ -423,8 +424,11 @@ class SuperClient(object):
             % (str(self.wrapped.__class__), attr, repr(args), repr(kwargs)))
             % (str(self.wrapped.__class__), attr, repr(args), repr(kwargs)))
           ret = res(*args, **kwargs)
           ret = res(*args, **kwargs)
           log_msg = repr(ret)
           log_msg = repr(ret)
-          if len(log_msg) > 1000:
-            log_msg = log_msg[0:1000] + "..."
+
+          # Truncate log message, increase output in DEBUG mode
+          log_limit = 2000 if settings.DEBUG else 1000
+          log_msg = log_msg[:log_limit] + (log_msg[log_limit:] and '...')
+          
           duration = time.time() - st
           duration = time.time() - st
 
 
           # Log the duration at different levels, depending on how long
           # Log the duration at different levels, depending on how long