Bug 1171032 - Log raw messages at debug level by default, r=chmanchester
authorJames Graham <james@hoppipolla.co.uk>
Wed, 03 Jun 2015 15:55:00 +0100
changeset 247141 4fe9665478958ce08c9c25e63dcceec52082de7d
parent 247140 8e0cdd01b1657038fbf12e355f7bb49e0a9338f5
child 247142 2eb48f83f8a8620ef0d5727d30eaf5b04a3b5eb6
push id28855
push userkwierso@gmail.com
push dateFri, 05 Jun 2015 01:19:30 +0000
treeherdermozilla-central@227d356ac030 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1171032
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1171032 - Log raw messages at debug level by default, r=chmanchester Also add --log-raw-level option to control this.
testing/mozbase/mozlog/mozlog/structured/commandline.py
--- a/testing/mozbase/mozlog/mozlog/structured/commandline.py
+++ b/testing/mozbase/mozlog/mozlog/structured/commandline.py
@@ -32,30 +32,36 @@ def verbose_wrapper(formatter, verbose):
 
 def buffer_handler_wrapper(handler, buffer_limit):
     if buffer_limit == "UNLIMITED":
         buffer_limit = None
     else:
         buffer_limit = int(buffer_limit)
     return handlers.BufferingLogFilter(handler, buffer_limit)
 
-formatter_option_defaults = {
-    'verbose': False,
-    'level': 'info',
-}
+def default_formatter_options(log_type):
+    formatter_option_defaults = {
+        "raw": {
+            "level": "debug"
+        }
+    }
+    rv = {"verbose": False,
+          "level": "info"}
+    rv.update(formatter_option_defaults.get(log_type, {}))
+    return rv
 
 fmt_options = {
     # <option name>: (<wrapper function>, description, <applicable formatters>, action)
     # "action" is used by the commandline parser in use.
     'verbose': (verbose_wrapper,
                 "Enables verbose mode for the given formatter.",
                 ["mach"], "store_true"),
     'level': (level_filter_wrapper,
               "A least log level to subscribe to for the given formatter (debug, info, error, etc.)",
-              ["mach", "tbpl"], "store"),
+              ["mach", "raw", "tbpl"], "store"),
     'buffer': (buffer_handler_wrapper,
                "If specified, enables message buffering at the given buffer size limit.",
                ["mach", "tbpl"], "store"),
 }
 
 
 def log_file(name):
     if name == "-":
@@ -169,17 +175,17 @@ def setup_logging(suite, args, defaults=
                      (coloured mach formatting if stdout is a terminal, or raw
                      logs otherwise).
 
     :rtype: StructuredLogger
     """
 
     logger = StructuredLogger(suite)
     # Keep track of any options passed for formatters.
-    formatter_options = defaultdict(lambda: formatter_option_defaults.copy())
+    formatter_options = {}
     # Keep track of formatters and list of streams specified.
     formatters = defaultdict(list)
     found = False
     found_stdout_logger = False
     if args is None:
         args = {}
     if not hasattr(args, 'iteritems'):
         args = vars(args)
@@ -204,24 +210,30 @@ def setup_logging(suite, args, defaults=
                     found = True
                     if isinstance(value, basestring):
                         value = log_file(value)
                     if value == sys.stdout:
                         found_stdout_logger = True
                     formatters[formatter].append(value)
             if len(parts) == 3:
                 _, formatter, opt = parts
+                if formatter not in formatter_options:
+                    formatter_options[formatter] = default_formatter_options(formatter)
                 formatter_options[formatter][opt] = values
 
     #If there is no user-specified logging, go with the default options
     if not found:
         for name, value in defaults.iteritems():
             formatters[name].append(value)
 
     elif not found_stdout_logger and sys.stdout in defaults.values():
         for name, value in defaults.iteritems():
             if value == sys.stdout:
                 formatters[name].append(value)
 
+    for name in formatters:
+        if name not in formatter_options:
+            formatter_options[name] = default_formatter_options(name)
+
     setup_handlers(logger, formatters, formatter_options)
     set_default_logger(logger)
 
     return logger