diff --git a/artifact/preload.go b/artifact/preload.go index 3c3ed69..f247ba7 100644 --- a/artifact/preload.go +++ b/artifact/preload.go @@ -37,7 +37,7 @@ func preload(q *qemu.System, ki distro.KernelInfo, pm PreloadModule, var workPath, cache string if pm.Path != "" { - log.Print("Use non-git path for preload module (no cache)") + log.Debug().Msg("Use non-git path for preload module (no cache)") workPath = pm.Path } else if pm.Repo != "" { workPath, cache, err = cloneOrPull(pm.Repo, ki) @@ -85,7 +85,7 @@ func buildAndInsmod(workPath string, q *qemu.System, ki distro.KernelInfo, output, err := q.CopyAndInsmod(af) if err != nil { - log.Print(output) + log.Error().Err(err).Msg(output) return } return @@ -147,7 +147,7 @@ func cloneOrPull(repo string, ki distro.KernelInfo) (workPath, cache string, err = w.Pull(&git.PullOptions{}) if err != nil && err != git.NoErrAlreadyUpToDate { - log.Print(repo, "pull error:", err) + log.Error().Err(err).Msgf("pull %s error", repo) } } else { r, err = git.PlainClone(workPath, false, &git.CloneOptions{URL: repo}) diff --git a/cmd/debug.go b/cmd/debug.go index c40e95d..9951466 100644 --- a/cmd/debug.go +++ b/cmd/debug.go @@ -45,7 +45,7 @@ type DebugCmd struct { func (cmd *DebugCmd) Run(g *Globals) (err error) { kcfg, err := config.ReadKernelConfig(g.Config.Kernels) if err != nil { - log.Print(err) + log.Error().Err(err).Msg("read kernel config") } var configPath string @@ -161,14 +161,14 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) { // Module depends on one of the standard modules err = artifact.CopyStandardModules(q, ki) if err != nil { - log.Print(err) + log.Error().Err(err).Msg("copy standard modules") return } } err = artifact.PreloadModules(q, ka, ki, g.Config.Docker.Timeout.Duration) if err != nil { - log.Print(err) + log.Error().Err(err).Msg("preload modules") return } @@ -182,7 +182,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) { } else { buildDir, outFile, output, err = artifact.Build(log.Logger, tmp, ka, ki, g.Config.Docker.Timeout.Duration) if err != nil { - log.Print(err, output) + log.Error().Err(err).Msg(output) return } @@ -206,7 +206,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) { } err = q.CopyFile(f.User, f.Local, f.Remote) if err != nil { - log.Print("error copy err:", err, f.Local, f.Remote) + log.Error().Err(err).Msgf("copy %s -> %s", f.Local, f.Remote) return } } diff --git a/cmd/kernel.go b/cmd/kernel.go index a5e1cea..02f1e19 100644 --- a/cmd/kernel.go +++ b/cmd/kernel.go @@ -263,7 +263,7 @@ func (cmd *KernelCmd) Generate(g *Globals, km artifact.Target) (err error) { } if cmd.stats.success >= cmd.Max { - log.Print("Max is reached") + log.Info().Msg("Max is reached") swg.Done() break } diff --git a/cmd/log.go b/cmd/log.go index e380776..77b97b8 100644 --- a/cmd/log.go +++ b/cmd/log.go @@ -42,7 +42,7 @@ func (cmd *LogQueryCmd) Run(g *Globals) (err error) { ka, kaErr := artifact.Artifact{}.Read(g.WorkDir + "/.out-of-tree.toml") if kaErr == nil { - log.Print(".out-of-tree.toml found, filter by artifact name") + log.Debug().Msg(".out-of-tree.toml found, filter by artifact name") les, err = getAllArtifactLogs(db, cmd.Tag, cmd.Num, ka) } else { les, err = getAllLogs(db, cmd.Tag, cmd.Num) diff --git a/cmd/pack.go b/cmd/pack.go index e676521..7eaffce 100644 --- a/cmd/pack.go +++ b/cmd/pack.go @@ -33,7 +33,7 @@ type PackCmd struct { func (cmd *PackCmd) Run(g *Globals) (err error) { tag := fmt.Sprintf("pack_run_%d", time.Now().Unix()) - log.Print("Tag:", tag) + log.Info().Msgf("Tag: %s", tag) files, err := os.ReadDir(g.WorkDir) if err != nil { @@ -65,7 +65,7 @@ func (cmd *PackCmd) Run(g *Globals) (err error) { } } - log.Print(f.Name()) + log.Info().Msg(f.Name()) pew := PewCmd{ Max: cmd.KernelRuns, diff --git a/kernel/kernel_linux.go b/kernel/kernel_linux.go index f165189..6d57436 100644 --- a/kernel/kernel_linux.go +++ b/kernel/kernel_linux.go @@ -34,7 +34,7 @@ func GenHostKernels(download bool) (kernels []distro.KernelInfo, err error) { rawOutput, err := cmd.CombinedOutput() if err != nil { - log.Print(string(rawOutput), err) + log.Error().Err(err).Msg(string(rawOutput)) return } @@ -86,7 +86,7 @@ func GenHostKernels(download bool) (kernels []distro.KernelInfo, err error) { } vmlinux := "/usr/lib/debug/boot/vmlinux-" + krel - log.Print("vmlinux", vmlinux) + log.Info().Msgf("vmlinux %s", vmlinux) if fs.PathExists(vmlinux) { ki.VmlinuxPath = vmlinux }