Skip to content

Conversation

@jakecorrenti
Copy link
Member

@jakecorrenti jakecorrenti commented Sep 2, 2025

The goal of this PR is to update how krunkit performs logging. It moves away from using the krun_set_log_level API in favor of the newer, and more configurable, krun_init_logs to configure the libkrun logging behavior. The intent of these changes is for krunkit to follow similar behavior by exposing to the user a --log-file option to specify where they want their logs output to.

Fixes: #52

@jakecorrenti jakecorrenti changed the title WIP: context: use krun_init_logs API Update logging Sep 2, 2025
@jakecorrenti jakecorrenti changed the title Update logging WIP: Update logging Sep 2, 2025
@jakecorrenti jakecorrenti force-pushed the logfile-option branch 6 times, most recently from 7c072ab to 43a8295 Compare September 3, 2025 14:26
@jakecorrenti jakecorrenti marked this pull request as ready for review September 3, 2025 14:44
@jakecorrenti jakecorrenti changed the title WIP: Update logging Update logging Sep 3, 2025
@nirs
Copy link
Contributor

nirs commented Sep 3, 2025

Missing docs, so not clear what is the behavior change. Can you add the missing docs changes we can start with the user experience and how this affects programs running krunkit?

I see this is added in the last commit, will check it.


- `--krun-log-level`

Set the log level for libkrun. Supported values: 0=off, 1=error, 2=warn, 3=info (default), 4=debug, 5 or more=trace.
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this was discussed in the past, but this log level is not compatible with vfkit, and not easy to use. We should really support the standard log level as strings:

  • trace
  • debug
  • info
  • warn
  • error

I don't see a need for 0 off. Why would someone want to disable errors in the log? We should not help to user to shoot themself in the foot. They can always redirect the log to /dev/null or with the new --log-file use /dev/null.

To keep the option to use numbers, we can support strings values and any integer. if the value is not one of the level names, convert the int. If not an int, fail. If and int, just use the int. This will keep everyone happy.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not really related to this change, I can open an issue to discuss this.

@jakecorrenti jakecorrenti force-pushed the logfile-option branch 3 times, most recently from ae8cf1a to fb27d71 Compare September 4, 2025 00:11
Moves away from using the `krun_set_log_level` API in favor of the
newer, and more configurable, `krun_init_log`.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Add a new `--log-file` option that allows the user to specify a path in
which krunkit and libkrun will write the logs.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Rather than printing out any logs to stdout through `println!`, we
should be using the log crate.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
@jakecorrenti
Copy link
Member Author

@slp WDYT about adding this to the next minor release if we're going to do one for #75

Copy link
Member

@tylerfanelli tylerfanelli left a comment

Choose a reason for hiding this comment

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

LGTM.

@jakecorrenti jakecorrenti merged commit 40b5678 into containers:main Sep 24, 2025
3 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.

Log to stderr

4 participants