Bug 1073093 - [mozlog] make sure formatter wasn't removed from defaults before adding commandline option for it, r=chmanchester
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 14 Nov 2014 09:23:22 -0500
changeset 215778 c6ab97a41edba799edbdc3f50a1c4d1a4bc29380
parent 215777 6e664f1aed21dd69ab4aa203106d5868f356f4d2
child 215779 2caae1e336488191a0bfffda09a4ec3f93a078c5
push id51850
push userahalberstadt@mozilla.com
push dateFri, 14 Nov 2014 14:31:51 +0000
treeherdermozilla-inbound@c6ab97a41edb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1073093
milestone36.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 1073093 - [mozlog] make sure formatter wasn't removed from defaults before adding commandline option for it, r=chmanchester
testing/mozbase/mozlog/mozlog/structured/commandline.py
--- a/testing/mozbase/mozlog/mozlog/structured/commandline.py
+++ b/testing/mozbase/mozlog/mozlog/structured/commandline.py
@@ -71,30 +71,34 @@ def add_logging_group(parser):
         group = optparse.OptionGroup(parser,
                                      group_name,
                                      group_description)
         for name, (cls, help_str) in log_formatters.iteritems():
             group.add_option("--log-" + name, action="append", type="str",
                              help=help_str)
         for optname, (cls, help_str, formatters, action) in fmt_options.iteritems():
             for fmt in formatters:
-                group.add_option("--log-%s-%s" % (fmt, optname), action=action,
-                                 help=help_str, default=None)
+                # make sure fmt wasn't removed from log_formatters
+                if fmt in log_formatters:
+                    group.add_option("--log-%s-%s" % (fmt, optname), action=action,
+                                     help=help_str, default=None)
         parser.add_option_group(group)
     else:
         group = parser.add_argument_group(group_name,
                                           group_description)
         for name, (cls, help_str) in log_formatters.iteritems():
             group.add_argument("--log-" + name, action="append", type=log_file,
                                help=help_str)
 
         for optname, (cls, help_str, formatters, action) in fmt_options.iteritems():
             for fmt in formatters:
-                group.add_argument("--log-%s-%s" % (fmt, optname), action=action,
-                                   help=help_str, default=None)
+                # make sure fmt wasn't removed from log_formatters
+                if fmt in log_formatters:
+                    group.add_argument("--log-%s-%s" % (fmt, optname), action=action,
+                                       help=help_str, default=None)
 
 
 def setup_handlers(logger, formatters, formatter_options):
     """
     Add handlers to the given logger according to the formatters and
     options provided.
 
     :param logger: The logger configured by this function.