Auto-tools/Projects/Structured Logging

From MozillaWiki
Jump to navigation Jump to search

This page is a high level account of the structured logging project providing links to further information about the project.

Background and Motivation

Goals:

  • Support a range of output formats for test results
  • Eliminate complex and brittle regex based log parsing
  • Consolidate output processing and logging configuration

Approach:

  • Establish a common data format for test results and test harness diagnostics
  • Populate data format in-harness with a logging API designed to output this format
  • Log data from test harnesses as JSON rather than formatted strings

Implementation

Participant Systems

  • Producer process (Firefox/Fennec/B2G - JS/Java)
  • Test harness (Python/JS)
  • Mozharness/Buildbot
  • Tbpl/Treeherder
  • Blobber

Logging APIs

The primary logging API for our data format is mozlog's structured module (readthedocs). An extensive example of how to use the api is included in these docs.

For data originating from JavaScript or Java, StructuredLog.jsm and StructuredLogger.java have been implemented to produce this data format. Mozlog supports logging data directly from these producers.

Status

  • The tracking bug for this effort is bug916295.
  • An etherpad with high-level status updates per test harness is maintained for the time being.
  • The initial goal of this project is to convert our main producers of logs, the test harnesses, to produce structured test results. Raw JSON logs are exposed as a blobber upload while integration with other systems is ongoing.

Structured Logging FAQ

What does this mean for you? It’s been a goal of the implementation effort to provide a foundation for future tools and infrastructure improvements without disrupting familiar workflows or breaking compatibility with existing tools, so the changes will be largely unobtrusive at this stage. However, there are two things to keep in mind:

  • Support for failing a build/test job by logging “TEST-UNEXPECTED-“ directly will be diminished as we move away from regex parsing in our tools. Please do not add instances of this when something else is available.
  • As we roll out this out to the various harnesses you may notice different output formats than you expected. Changes to formatting shouldn’t make logs any less useful — if they have, this is probably an unintended effect of the implementation and you should file a bug (Testing :: Mozbase for mozlog features/bugs). To get output closer to what you used to see, you should be able to pass “—log-tbpl -“ to mach to specify a formatter implementing the legacy log format.