Bug 1439411 - [mozlog] Document built-in CLI logging options r=jgraham

The output formatters provided by mozlog are well-documented in the
online help guide, but this information is not available to users in the
CLI. The `add_logging_group` method extends the consuming project's
command-line interface without referencing mozlog itself. This means
consumers may not have a means to discover the additional information,
and even in cases where they can infer this connection, there is no
indication of the stability of the behavior.

Extend the description of the built-in output formatters to explain
their origin and reference the relevant documentation.

--HG--
extra : histedit_source : 9069af86efc67232e059176f99a877c513644ce2
This commit is contained in:
Mike Pennisi 2018-02-26 08:29:00 +02:00
parent 0342fd5418
commit fb163fbacb

View File

@ -15,12 +15,18 @@ from . import formatters
from .structuredlog import StructuredLogger, set_default_logger
log_formatters = {
'raw': (formatters.JSONFormatter, "Raw structured log messages"),
'unittest': (formatters.UnittestFormatter, "Unittest style output"),
'xunit': (formatters.XUnitFormatter, "xUnit compatible XML"),
'html': (formatters.HTMLFormatter, "HTML report"),
'mach': (formatters.MachFormatter, "Human-readable output"),
'tbpl': (formatters.TbplFormatter, "TBPL style log format"),
'raw': (formatters.JSONFormatter, "Raw structured log messages "
"(provided by mozlog)"),
'unittest': (formatters.UnittestFormatter, "Unittest style output "
"(provided by mozlog)"),
'xunit': (formatters.XUnitFormatter, "xUnit compatible XML "
"(povided by mozlog)"),
'html': (formatters.HTMLFormatter, "HTML report "
"(provided by mozlog)"),
'mach': (formatters.MachFormatter, "Human-readable output "
"(provided by mozlog)"),
'tbpl': (formatters.TbplFormatter, "TBPL style log format "
"(provided by mozlog)"),
'errorsummary': (formatters.ErrorSummaryFormatter, argparse.SUPPRESS),
}
@ -28,6 +34,9 @@ TEXT_FORMATTERS = ('raw', 'mach')
"""a subset of formatters for non test harnesses related applications"""
DOCS_URL = "https://firefox-source-docs.mozilla.org/mozbase/mozlog.html"
def level_filter_wrapper(formatter, level):
return handlers.LogLevelFilter(formatter, level)
@ -121,7 +130,9 @@ def add_logging_group(parser, include_formatters=None):
group_name = "Output Logging"
group_description = ("Each option represents a possible logging format "
"and takes a filename to write that format to, "
"or '-' to write to stdout.")
"or '-' to write to stdout. Some options are "
"provided by the mozlog utility; see %s "
"for extended documentation." % DOCS_URL)
if include_formatters is None:
include_formatters = list(log_formatters.keys())