Skip to content

Commit

Permalink
more log fixes (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
decentralgabe authored Apr 10, 2024
1 parent 9341469 commit ff798b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/image-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:

build-and-push-ssi:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
12 changes: 5 additions & 7 deletions impl/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)
}
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions impl/internal/cli/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ff798b0

Please sign in to comment.