Browse Source

[Backend] Fixing hue debug level issue

What changes were proposed in this pull request?
• Fixing DEBUG/INFO issue in logging.
How was this patch tested?
• Tested manually
Prakash Ranade 2 years ago
parent
commit
0c9360b719

+ 3 - 2
desktop/conf.dist/log.conf

@@ -38,7 +38,8 @@ qualname=requests.packages.urllib3.connectionpool
 
 [logger_django_db]
 level=DEBUG
-handlers=errorlog
+handlers=logfile
+propogate=False
 qualname=django.db.backends
 
 [logger_boto]
@@ -92,4 +93,4 @@ keys=root,access,django_auth_ldap,kazoo_client,requests_packages_urllib3_connect
 keys=stderr,logfile,accesslog,errorlog
 
 [formatters]
-keys=default,access
+keys=default,access

+ 3 - 2
desktop/conf/log.conf

@@ -38,7 +38,8 @@ qualname=requests.packages.urllib3.connectionpool
 
 [logger_django_db]
 level=DEBUG
-handlers=errorlog
+handlers=logfile
+propogate=False
 qualname=django.db.backends
 
 [logger_boto]
@@ -92,4 +93,4 @@ keys=root,access,django_auth_ldap,kazoo_client,requests_packages_urllib3_connect
 keys=stderr,logfile,accesslog,errorlog
 
 [formatters]
-keys=default,access
+keys=default,access

+ 1 - 1
desktop/core/src/desktop/lib/raz/raz_client.py

@@ -38,7 +38,7 @@ else:
   from urllib import unquote as lib_urlunquote
 
 
-LOG = logging.getLogger(__name__)
+LOG = logging.getLogger()
 
 
 class RazClient(object):

+ 14 - 2
desktop/core/src/desktop/log/__init__.py

@@ -27,7 +27,7 @@ import re
 import sys
 
 from logging import FileHandler
-from logging.handlers import RotatingFileHandler
+from logging.handlers import RotatingFileHandler, SocketHandler
 
 from desktop.lib.paths import get_desktop_root
 from desktop.log import formatter
@@ -186,7 +186,8 @@ def basic_logging(proc_name, log_dir=None):
       handler = logging.StreamHandler()
       handler.setFormatter(logging.Formatter(LOG_FORMAT, DATE_FORMAT))
       root_logger.addHandler(handler)
-    handler.setLevel(lvl)
+    if handler:
+      handler.setLevel(lvl)
 
     # Set all loggers but error.log to the same logging level
     for h in root_logger.__dict__['handlers']:
@@ -194,6 +195,17 @@ def basic_logging(proc_name, log_dir=None):
         if os.path.basename(h.baseFilename) != 'error.log':
           h.setLevel(lvl)
 
+    # Set all loggers but error.log to the same logging level
+    for h in root_logger.__dict__['handlers']:
+      if isinstance(h, (SocketHandler)) and h.level != 40:
+        h.setLevel(lvl)
+
+    from desktop.conf import DATABASE_LOGGING
+    if not DATABASE_LOGGING.get():
+      def disable_database_logging():
+        logger = logging.getLogger()
+        logger.manager.loggerDict['django.db.backends'].level = 20 # INFO level
+      disable_database_logging()
 
 def fancy_logging():
   """Configure logging into a buffer for /logs endpoint."""

+ 1 - 1
desktop/core/src/desktop/management/commands/rungunicornserver.py

@@ -182,7 +182,7 @@ def rungunicornserver(args=[], options={}):
       'limit_request_field_size': conf.LIMIT_REQUEST_FIELD_SIZE.get(),
       'limit_request_fields': conf.LIMIT_REQUEST_FIELDS.get(),
       'limit_request_line': conf.LIMIT_REQUEST_LINE.get(),
-      'loglevel': 'info',
+      'loglevel': 'DEBUG' if conf.DJANGO_DEBUG_MODE.get() else 'INFO',
       'max_requests': 1200,                   # The maximum number of requests a worker will process before restarting.
       'max_requests_jitter': 0,
       'paste': None,