Auto-tools/Projects/Structured Logging
This page is a high level account of the structured logging project providing links to further information about the project.
Contents
Background and Motivation
Goals:
- Support a range of output formats for test results
- Eliminate need for 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 test framework (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.
Mozlog is a module in Mozbase. More information about contributing to Mozbase can be found on its wiki page: https://wiki.mozilla.org/Auto-tools/Projects/MozBase#Working_on_Mozbase_and_Contributing_Patches
Mozlog bugs:
21 Total; 21 Open (100%); 0 Resolved (0%); 0 Verified (0%);
For data originating from JavaScript or Java, StructuredLog.jsm and StructuredLogger.java have been implemented to produce this format. Mozlog supports logging data directly from these producers.
Status
- The tracking bug for this effort is bug916295.
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.