Configurable log line formatting
It has been requested on multiple occasions now to change the logging format for the log lines which BuildStream produces.
Our stance on this has been hard, because we cannot please everyone with the default, and our priorities at least for the master log is to create the most comfortable UI as possible (this mostly means limiting log line length to avoid wrapping on most terminals, and aligning things in log lines so that they are easy to scan by eye); while the more detailed logs showing how things got built are stored in files and artifacts themselves.
To alleviate this friction and give users what they are asking for, we need to make the LogLine()
a bit configurable.
Since the LogLine()
is already composed of Widget()
subclasses in the frontend to print various aspects of a Message()
object; it should be fairly straight forward to construct the LogLine()
widgets based on a format string indicating what widget should be printed and where.
This API is intended to be symmetric, or similar to the format strings used for bst show
and formatting of how elements should be printed at the beginning of a session.
The initial two additions we need to add to the existing things we already print include:
- Wall clock time
- Currently printed elapsed time but with microsecond precision instead of the default second precision
A tentative look at what the config might look like in buildstream.conf:
logging:
log-line-format: |
[%{elapsed}][%{key}][%{element}] %{action} %{message}