浏览代码

[core] Prettify unifying the general log level

Romain Rigaux 9 年之前
父节点
当前提交
aac6fcb
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      desktop/core/src/desktop/log/__init__.py

+ 7 - 4
desktop/core/src/desktop/log/__init__.py

@@ -23,6 +23,7 @@ import re
 import sys
 
 from cStringIO import StringIO
+from logging import FileHandler
 from logging.handlers import RotatingFileHandler
 
 from desktop.lib.paths import get_desktop_root
@@ -175,10 +176,12 @@ def basic_logging(proc_name, log_dir=None):
       handler.setFormatter(logging.Formatter(LOG_FORMAT, DATE_FORMAT))
       root_logger.addHandler(handler)
     handler.setLevel(lvl)
-    for h in root_logger.__dict__['handlers']:
-      if h.__class__.__name__ == 'FileHandler' or h.__class__.__name__ == 'RotatingFileHandler':
-        if h.baseFilename.split('/')[-1] != 'error.log':
-          h.setLevel(lvl)
+
+    # Set all loggers but error.log to the same logging level
+    error_handler = logging.getLogger('handler_errorlog')
+    for h in root_logger.handlers:
+      if isinstance(h, (FileHandler, RotatingFileHandler)) and h != error_handler:
+        h.setLevel(lvl)
 
 
 def fancy_logging():