PSA: mach now stores its log automatically

It's been a frustration for a long time: oftentimes, you need to dig the log of the build or test run you just did, but didn't redirect it. When you have enough backlog in your terminal, that can work itself out, but usually, what happens is that you rerun the command, redirecting it to a log file, hoping what you're looking for will happen again.

For people working on the build system, it's even worse because it involves someone else: someone comes and say "my build fails with $message", and usually, thanks to parallel builds, the actual error message is buried deep in their terminal history... when they have a terminal history (Windows console, I'm looking at you).

Anyways, as of bug 985857, as long as you don't already redirect mach's output to a file, it will now save it for you automatically.

At the moment, the feature is basic, and will store the last log of the last command (mostly). So if you run mach build followed by mach xpcshell-test, only the log for the latter will be available, and the log of the former will be lost.

The log is stored in the same format as mach uses when you give it the -l argument, which is an aggregate of many json pieces, and not very user friendly. Which is why mach now also has a new command to read those logs:

mach show-log

By default, it will display the last log mach stored, but you can also give it the path to any log you got out of mach with the -l argument.

So you can do either:

mach <command>
mach show-log


mach -l log-file.json <command>
mach show-log log-file.json

Note that show-log will spawn less automatically, so that you have paging and search abilities.

2015-06-10 06:01:13+0900


Responses are currently closed, but you can trackback from your own site.

2 Responses to “PSA: mach now stores its log automatically”

  1. jgraham Says:

    Hmm, afaict this only works for a rather small subset of commands. At least it only worked for me with |mach build|, not with mochitest, xpcshell-test or web-platform-tests. We discussed doing something similar for the test commands in bug 1167680 (which is not that clearly scoped).

    It also looks like the build log format is not quite compatible with the structured logging format we are using for test jobs. I guess some unification here could be a nice idea.

  2. glandium Says:

    jgraham: Then that means those mach commands are sending their output directly to stdout instead of having mach treat it. Anything that inherits MachCommandBase should be logged… except if their output is sent to stdout directly.