From d4a3a91c0e86ba6ed1b2d17db19a16447d8f8518 Mon Sep 17 00:00:00 2001 From: gabe Date: Wed, 10 Apr 2024 00:04:32 -0400 Subject: [PATCH] more log fixes --- .github/workflows/image-publish.yml | 2 +- impl/cmd/main.go | 12 +++++------- impl/internal/cli/store.go | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/image-publish.yml b/.github/workflows/image-publish.yml index 323bad21..db09f038 100644 --- a/.github/workflows/image-publish.yml +++ b/.github/workflows/image-publish.yml @@ -17,7 +17,7 @@ env: jobs: - build-and-push-ssi: + build-and-push-image: runs-on: ubuntu-latest permissions: contents: read diff --git a/impl/cmd/main.go b/impl/cmd/main.go index 7c42163c..cf62fddc 100644 --- a/impl/cmd/main.go +++ b/impl/cmd/main.go @@ -31,9 +31,7 @@ import ( // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html func main() { - logrus.SetFormatter(&logrus.JSONFormatter{ - PrettyPrint: true, - }) + logrus.SetFormatter(&logrus.JSONFormatter{}) logrus.SetReportCaller(true) log := logrus.NewEntry(logrus.StandardLogger()).WithField("version", config.Version) @@ -47,7 +45,7 @@ func main() { func run() error { ctx := context.Background() if err := telemetry.SetupTelemetry(ctx); err != nil { - logrus.WithError(err).Fatal("error initializing telemetry") + logrus.WithContext(ctx).WithError(err).Fatal("error initializing telemetry") } defer telemetry.Shutdown(ctx) @@ -68,7 +66,7 @@ func run() error { if logFile := configureLogger(cfg.Log.Level, cfg.Log.Path); logFile != nil { defer func(logFile *os.File) { if err = logFile.Close(); err != nil { - logrus.WithError(err).Error("failed to close log file") + logrus.WithContext(ctx).WithError(err).Error("failed to close log file") } }(logFile) } @@ -80,12 +78,12 @@ func run() error { d, err := dht.NewDHT(cfg.DHTConfig.BootstrapPeers) if err != nil { - return util.LoggingErrorMsg(err, "failed to instantiate dht") + return util.LoggingCtxErrorMsg(ctx, err, "failed to instantiate dht") } s, err := server.NewServer(cfg, shutdown, d) if err != nil { - return util.LoggingErrorMsg(err, "could not start http services") + return util.LoggingCtxErrorMsg(ctx, err, "could not start http services") } serverErrors := make(chan error, 1) diff --git a/impl/internal/cli/store.go b/impl/internal/cli/store.go index 2ba0819f..99603f3a 100644 --- a/impl/internal/cli/store.go +++ b/impl/internal/cli/store.go @@ -17,11 +17,11 @@ const ( // Read reads the diddht file and returns the identities. func Read() (internal.Identities, error) { homeDir, _ := os.UserHomeDir() - diddhtFile := homeDir + didDHTPath - if _, err := os.Stat(diddhtFile); os.IsNotExist(err) { + didDHTFile := homeDir + didDHTPath + if _, err := os.Stat(didDHTFile); os.IsNotExist(err) { return nil, util.LoggingErrorMsg(err, "failed to find diddht file") } - f, _ := os.Open(diddhtFile) + f, _ := os.Open(didDHTFile) defer f.Close() var identities internal.Identities if err := json.NewDecoder(f).Decode(&identities); err != nil {