From 7cb5877fd05f9dc40c2c62858ff2ddfd7b5fd864 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Mon, 7 Oct 2024 16:47:39 +0000 Subject: [PATCH] refactor: logs --- artifact/artifact.go | 5 +++-- artifact/process.go | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/artifact/artifact.go b/artifact/artifact.go index dd1510a..61d149d 100644 --- a/artifact/artifact.go +++ b/artifact/artifact.go @@ -12,7 +12,6 @@ import ( "github.com/naoina/toml" "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "code.dumpstack.io/tools/out-of-tree/config/dotfiles" "code.dumpstack.io/tools/out-of-tree/distro" @@ -338,8 +337,10 @@ func (ka Artifact) Process(slog zerolog.Logger, ki distro.KernelInfo, slog.Debug().Str("duration", time.Since(start).String()). Msg("build done") if err != nil { - log.Error().Err(err).Msg("build") + slog.Error().Err(err).Msg("build") return + } else { + slog.Info().Err(err).Msg("build success") } result.Build.Ok = true } else { diff --git a/artifact/process.go b/artifact/process.go index 275b1dd..80b360d 100644 --- a/artifact/process.go +++ b/artifact/process.go @@ -313,8 +313,7 @@ func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact, res.Test.Output, err = testKernelModule(q, ka, remoteTest) if err != nil { - slog.Error().Err(err).Msg(res.Test.Output) - return + break } res.Test.Ok = true case KernelExploit: @@ -327,16 +326,14 @@ func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact, res.Test.Output, err = testKernelExploit(q, ka, remoteTest, remoteExploit) if err != nil { - slog.Error().Err(err).Msg(res.Test.Output) - return + break } res.Run.Ok = true // does not really used res.Test.Ok = true case Script: res.Test.Output, err = runScript(q, remoteTest) if err != nil { - slog.Error().Err(err).Msg(res.Test.Output) - return + break } res.Run.Ok = true res.Test.Ok = true @@ -344,7 +341,12 @@ func copyArtifactAndTest(slog zerolog.Logger, q *qemu.System, ka Artifact, slog.Fatal().Msg("Unsupported artifact type") } - slog.Info().Msgf("\n%v\n", res.Test.Output) + if err != nil || !res.Test.Ok { + slog.Error().Err(err).Msgf("test error\n%v\n", res.Test.Output) + return + } + + slog.Info().Msgf("test success\n%v\n", res.Test.Output) _, err = q.Command("root", "echo") if err != nil {