From 6048a58d286ce3432bc18b0d472064c05d1d1636 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 17 Sep 2018 12:17:52 +0200 Subject: [PATCH] Add more verbose processing logs Signed-off-by: Knut Ahlers --- main.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 50c1354..7e6a6bf 100644 --- a/main.go +++ b/main.go @@ -270,27 +270,31 @@ func downloadAssets(res http.ResponseWriter, r *http.Request) { } func jobProcessor(uid uuid.UUID) { + logger := log.WithField("uuid", uid) + logger.Info("Started processing") + processingDir := path.Dir(pathFromUUID(uid, filenameStatus)) status, err := loadStatusByUUID(uid) if err != nil { - log.WithError(err).Error("Unable to load status file in processing job") + logger.WithError(err).Error("Unable to load status file in processing job") return } cmd := exec.Command("/bin/bash", cfg.Script) // #nosec G204 cmd.Dir = processingDir - cmd.Stderr = log.StandardLogger().WriterLevel(log.ErrorLevel) + cmd.Stderr = logger.WriterLevel(log.InfoLevel) // Bash uses stderr for `-x` parameter status.UpdateStatus(statusStarted) if err := status.Save(); err != nil { - log.WithError(err).Error("Unable to save status file") + logger.WithError(err).Error("Unable to save status file") return } if err := cmd.Run(); err != nil { + logger.WithError(err).Error("Processing failed") status.UpdateStatus(statusError) if err := status.Save(); err != nil { - log.WithError(err).Error("Unable to save status file") + logger.WithError(err).Error("Unable to save status file") return } return @@ -298,7 +302,8 @@ func jobProcessor(uid uuid.UUID) { status.UpdateStatus(statusFinished) if err := status.Save(); err != nil { - log.WithError(err).Error("Unable to save status file") + logger.WithError(err).Error("Unable to save status file") return } + logger.Info("Finished processing") }