Skip to content

Improve log output#4199

Merged
daandemeyer merged 2 commits intosystemd:mainfrom
pothos:logprefix
Mar 16, 2026
Merged

Improve log output#4199
daandemeyer merged 2 commits intosystemd:mainfrom
pothos:logprefix

Conversation

@pothos
Copy link
Contributor

@pothos pothos commented Mar 2, 2026

  • Add context to log output

    Currently it's not really easy to know which log output belongs to which
    mkosi image when there's the tools tree image, the main image, and any
    sub images.
    Add a log prefix that remembers the current image so that it's not just
    "‣ Installing Fedora Linux" but "‣ [tools] Installing Fedora Linux",
    "‣ [default-initrd] Installing Fedora Linux", and
    "‣ [main] Installing Fedora Linux".

  • Allow printing of step durations with CLI flag

    The printing of the duration for each step was behind the --debug flag
    which adds more noise when one is just interested in the build times.
    Also, the printing of the step duration serves as good marker during
    log reading to understand where the above log output belongs to.
    Add a new --log-timing flag to always print the step durations.

I first thought about prefixing all output lines but with the two changes above it works well enough to frame long output. Prefixing all output including the scripts would mean to emulate a TTY so that colors and so on would still be used. That could be a good idea as well if one needs timestamps for every line but I think that would be something for another PR.

Copy link
Contributor

@behrmann behrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

@pothos pothos force-pushed the logprefix branch 3 times, most recently from 094c366 to 4832585 Compare March 2, 2026 16:24
@pothos
Copy link
Contributor Author

pothos commented Mar 2, 2026

Had to rebase but since I moved the IMAGE.set to the build_image function I wanted to test again but ran into some other issue with latest main.

@pothos
Copy link
Contributor Author

pothos commented Mar 3, 2026

Should be good now

Copy link
Contributor

@behrmann behrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this, just scrolled the CI logs and this does improve orientation quite a bit.

mkosi/config.py Outdated
default=False,
)
parser.add_argument(
"--log-timing",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name this --debug-perf or --debug-timing or so?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be added to the man page as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Went with debug-timing.

mkosi/config.py Outdated
default=False,
)
parser.add_argument(
"--log-timing",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be added to the man page as well

pothos added 2 commits March 16, 2026 21:14
Currently it's not really easy to know which log output belongs to which
mkosi image when there's the tools tree image, the main image, and any
sub images.
Add a log prefix that remembers the current image so that it's not just
"‣  Installing Fedora Linux" but  "‣ [tools]  Installing Fedora Linux",
"‣ [default-initrd]  Installing Fedora Linux", and
"‣ [main]  Installing Fedora Linux".
The printing of the duration for each step was behind the --debug flag
which adds more noise when one is just interested in the build times.
Also, the printing of the step duration serves as good marker during
log reading to understand where the above log output belongs to.
Add a new --debug-timing flag to always print the step durations.
@daandemeyer daandemeyer merged commit 3c79cef into systemd:main Mar 16, 2026
52 checks passed
@pothos pothos deleted the logprefix branch March 16, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants