Improve logging (#1158)

* switch default log level to info add start message and cleanup server start
* refactor code
* fix agent debug / trace logging
This commit is contained in:
Anbraten
2022-09-03 20:41:23 +02:00
committed by GitHub
parent 297732eab8
commit 5ca7ede9e4
6 changed files with 104 additions and 96 deletions

View File

@@ -13,8 +13,8 @@ import (
// Requests without errors are logged using log.Info().
//
// It receives:
// 1. A time package format string (e.g. time.RFC3339).
// 2. A boolean stating whether to use UTC time zone or local.
// 1. A time package format string (e.g. time.RFC3339).
// 2. A boolean stating whether to use UTC time zone or local.
func Logger(timeFormat string, utc bool) gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
@@ -42,7 +42,7 @@ func Logger(timeFormat string, utc bool) gin.HandlerFunc {
// Append error field if this is an erroneous request.
log.Error().Str("error", c.Errors.String()).Fields(entry).Msg("")
} else {
log.Info().Fields(entry).Msg("")
log.Debug().Fields(entry).Msg("")
}
}
}

View File

@@ -64,7 +64,7 @@ func Refresh(c *gin.Context) {
// if we really want to fail the request, do we?
log.Error().Msgf("cannot refresh access token for %s. %s", user.Login, err)
} else {
log.Info().Msgf("refreshed access token for %s", user.Login)
log.Debug().Msgf("refreshed access token for %s", user.Login)
}
}