Skip to content

Introduce a new krun_init_log() API #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 3, 2025
Merged

Introduce a new krun_init_log() API #326

merged 5 commits into from
Jun 3, 2025

Conversation

mtjhrc
Copy link
Collaborator

@mtjhrc mtjhrc commented May 2, 2025

Introduce a new krun_init_log public API function to allow for much detailed configuration of logging by the application. The main improvment is the ability to specify a file descriptor to write the log to.

This can be tested using the added chroot_vm flags: --log=/path/to/a/pipe or --color-log=/path/to/a/pipe (which will also display a formatting).

@mtjhrc mtjhrc force-pushed the log-api branch 3 times, most recently from 8c3c952 to d19939c Compare May 27, 2025 12:27
@mtjhrc mtjhrc marked this pull request as ready for review May 27, 2025 12:35
mtjhrc added 5 commits May 29, 2025 14:06
Introduce a new krun_init_log public API function to allow for much more
detailed configuration of logging by the application. The main improvment is
is the ability to specify a file descriptor to write the log to.

Signed-off-by: Matej Hrica <[email protected]>
chroot_vm is meant as an example and program to showcase libkrun APIs, we should
at least show error messages by default even without RUST_LOG env variable.

Signed-off-by: Matej Hrica <[email protected]>
Use the newer krun_init_log to support redirecting the log to a pipe.

Signed-off-by: Matej Hrica <[email protected]>
The correct way to use the env_logger crate is to only depend on it the toplevel
aplication crate. In other crates we should just use the `log` crate facade
(which we already do).

Drop the env_logger dependency from all of our internal crates, and just keep it
in the the `libkrun` crate.

Signed-off-by: Matej Hrica <[email protected]>
Use newest version of env_logger. This is needed to fix a problem where output
to a pipe ignores RUST_LOG_STYLE=always option and colors don't work.

Signed-off-by: Matej Hrica <[email protected]>
Copy link
Member

@jakecorrenti jakecorrenti left a comment

Choose a reason for hiding this comment

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

haven't had a chance to test it yet, but code LGTM!

Copy link
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@slp slp merged commit 3d08c75 into containers:main Jun 3, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants