1
0

refactor: logs

This commit is contained in:
dump_stack() 2024-05-23 10:19:46 +00:00
parent 317c6149ea
commit ab53de1286
Signed by: dump_stack
GPG Key ID: C9905BA72B5E02BB
6 changed files with 14 additions and 14 deletions

View File

@ -37,7 +37,7 @@ func preload(q *qemu.System, ki distro.KernelInfo, pm PreloadModule,
var workPath, cache string var workPath, cache string
if pm.Path != "" { 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 workPath = pm.Path
} else if pm.Repo != "" { } else if pm.Repo != "" {
workPath, cache, err = cloneOrPull(pm.Repo, ki) 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) output, err := q.CopyAndInsmod(af)
if err != nil { if err != nil {
log.Print(output) log.Error().Err(err).Msg(output)
return return
} }
return return
@ -147,7 +147,7 @@ func cloneOrPull(repo string, ki distro.KernelInfo) (workPath, cache string,
err = w.Pull(&git.PullOptions{}) err = w.Pull(&git.PullOptions{})
if err != nil && err != git.NoErrAlreadyUpToDate { if err != nil && err != git.NoErrAlreadyUpToDate {
log.Print(repo, "pull error:", err) log.Error().Err(err).Msgf("pull %s error", repo)
} }
} else { } else {
r, err = git.PlainClone(workPath, false, &git.CloneOptions{URL: repo}) r, err = git.PlainClone(workPath, false, &git.CloneOptions{URL: repo})

View File

@ -45,7 +45,7 @@ type DebugCmd struct {
func (cmd *DebugCmd) Run(g *Globals) (err error) { func (cmd *DebugCmd) Run(g *Globals) (err error) {
kcfg, err := config.ReadKernelConfig(g.Config.Kernels) kcfg, err := config.ReadKernelConfig(g.Config.Kernels)
if err != nil { if err != nil {
log.Print(err) log.Error().Err(err).Msg("read kernel config")
} }
var configPath string var configPath string
@ -161,14 +161,14 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
// Module depends on one of the standard modules // Module depends on one of the standard modules
err = artifact.CopyStandardModules(q, ki) err = artifact.CopyStandardModules(q, ki)
if err != nil { if err != nil {
log.Print(err) log.Error().Err(err).Msg("copy standard modules")
return return
} }
} }
err = artifact.PreloadModules(q, ka, ki, g.Config.Docker.Timeout.Duration) err = artifact.PreloadModules(q, ka, ki, g.Config.Docker.Timeout.Duration)
if err != nil { if err != nil {
log.Print(err) log.Error().Err(err).Msg("preload modules")
return return
} }
@ -182,7 +182,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
} else { } else {
buildDir, outFile, output, err = artifact.Build(log.Logger, tmp, ka, ki, g.Config.Docker.Timeout.Duration) buildDir, outFile, output, err = artifact.Build(log.Logger, tmp, ka, ki, g.Config.Docker.Timeout.Duration)
if err != nil { if err != nil {
log.Print(err, output) log.Error().Err(err).Msg(output)
return return
} }
@ -206,7 +206,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
} }
err = q.CopyFile(f.User, f.Local, f.Remote) err = q.CopyFile(f.User, f.Local, f.Remote)
if err != nil { 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 return
} }
} }

View File

@ -263,7 +263,7 @@ func (cmd *KernelCmd) Generate(g *Globals, km artifact.Target) (err error) {
} }
if cmd.stats.success >= cmd.Max { if cmd.stats.success >= cmd.Max {
log.Print("Max is reached") log.Info().Msg("Max is reached")
swg.Done() swg.Done()
break break
} }

View File

@ -42,7 +42,7 @@ func (cmd *LogQueryCmd) Run(g *Globals) (err error) {
ka, kaErr := artifact.Artifact{}.Read(g.WorkDir + "/.out-of-tree.toml") ka, kaErr := artifact.Artifact{}.Read(g.WorkDir + "/.out-of-tree.toml")
if kaErr == nil { 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) les, err = getAllArtifactLogs(db, cmd.Tag, cmd.Num, ka)
} else { } else {
les, err = getAllLogs(db, cmd.Tag, cmd.Num) les, err = getAllLogs(db, cmd.Tag, cmd.Num)

View File

@ -33,7 +33,7 @@ type PackCmd struct {
func (cmd *PackCmd) Run(g *Globals) (err error) { func (cmd *PackCmd) Run(g *Globals) (err error) {
tag := fmt.Sprintf("pack_run_%d", time.Now().Unix()) 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) files, err := os.ReadDir(g.WorkDir)
if err != nil { 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{ pew := PewCmd{
Max: cmd.KernelRuns, Max: cmd.KernelRuns,

View File

@ -34,7 +34,7 @@ func GenHostKernels(download bool) (kernels []distro.KernelInfo, err error) {
rawOutput, err := cmd.CombinedOutput() rawOutput, err := cmd.CombinedOutput()
if err != nil { if err != nil {
log.Print(string(rawOutput), err) log.Error().Err(err).Msg(string(rawOutput))
return return
} }
@ -86,7 +86,7 @@ func GenHostKernels(download bool) (kernels []distro.KernelInfo, err error) {
} }
vmlinux := "/usr/lib/debug/boot/vmlinux-" + krel vmlinux := "/usr/lib/debug/boot/vmlinux-" + krel
log.Print("vmlinux", vmlinux) log.Info().Msgf("vmlinux %s", vmlinux)
if fs.PathExists(vmlinux) { if fs.PathExists(vmlinux) {
ki.VmlinuxPath = vmlinux ki.VmlinuxPath = vmlinux
} }