diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-10-28 20:04:33 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-11-11 16:25:52 +0100 |
commit | 3fe0c49174e2fba6695dcedff449ba73d15943c8 (patch) | |
tree | 328890b774a3a53da9261c37caf02ddce710e9a8 /libpod/network | |
parent | 4febe557692aeec8ca9d9b9cdc732772ba7d5876 (diff) | |
download | podman-3fe0c49174e2fba6695dcedff449ba73d15943c8.tar.gz podman-3fe0c49174e2fba6695dcedff449ba73d15943c8.tar.bz2 podman-3fe0c49174e2fba6695dcedff449ba73d15943c8.zip |
Fix RUST_LOG envar for netavark
THe rust netlink library is very verbose. It contains way to much debug
and trave logs. We can set `RUST_LOG=netavark=<level>` to make sure this
log level only applies to netavark and not the libraries.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/network')
-rw-r--r-- | libpod/network/netavark/exec.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libpod/network/netavark/exec.go b/libpod/network/netavark/exec.go index 700df9a69..d6458eeb4 100644 --- a/libpod/network/netavark/exec.go +++ b/libpod/network/netavark/exec.go @@ -45,6 +45,18 @@ func newNetavarkError(msg string, err error) error { } } +// getRustLogEnv returns the RUST_LOG env var based on the current logrus level +func getRustLogEnv() string { + level := logrus.GetLevel().String() + // rust env_log uses warn instead of warning + if level == "warning" { + level = "warn" + } + // the rust netlink library is very verbose + // make sure to only log netavark logs + return "RUST_LOG=netavark=" + level +} + // execNetavark will execute netavark with the following arguments // It takes the path to the binary, the list of args and an interface which is // marshaled to json and send via stdin to netavark. The result interface is @@ -72,7 +84,7 @@ func execNetavark(binary string, args []string, stdin, result interface{}) error // connect stderr to the podman stderr for logging cmd.Stderr = os.Stderr // set the netavark log level to the same as the podman - cmd.Env = append(os.Environ(), "RUST_LOG="+logrus.GetLevel().String()) + cmd.Env = append(os.Environ(), getRustLogEnv()) // if we run with debug log level lets also set RUST_BACKTRACE=1 so we can get the full stack trace in case of panics if logrus.IsLevelEnabled(logrus.DebugLevel) { cmd.Env = append(cmd.Env, "RUST_BACKTRACE=1") |