Skip to content

Commit

Permalink
Replace logging.Log.Error() with logging.LogError() (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksanders authored Jan 14, 2022
1 parent e2aec9a commit 50ae0fa
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/creds/refreshable.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (rp *RefreshableProvider) AutoRefresh() {
case _ = <-ticker.C:
_, err := rp.checkAndRefresh(10)
if err != nil {
logging.Log.Error(err.Error())
logging.LogError(err, "failed to refresh credentials")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/httpAuth/mtls/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (wc *wrappedCertificate) autoRefresh() {
for _, file := range []string{wc.certFile, wc.keyFile} {
err = watcher.Add(file)
if err != nil {
logging.Log.Error(err)
logging.LogError(err, "failed to add file to watcher")
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/httpAuth/mtls/mtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func getTLSConfig() (*tls.Config, error) {

func makeTLSConfig(certFile, keyFile, caFile string, insecure bool) (*tls.Config, error) {
if certFile == "" || keyFile == "" || caFile == "" {
logging.Log.Error("MTLS cert, key, or CA file not defined in configuration")
logging.LogError(fmt.Errorf("mTLS cert, key, or CA file not defined in configuration"), "mTLS could not be initialized")
return nil, MissingTLSConfigError
}
caCert, _ := ioutil.ReadFile(caFile)
Expand Down
2 changes: 1 addition & 1 deletion pkg/logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ func RegisterLogger(l *logrus.Entry) {

// LogError is a helper function that allows for errors to be logged easily
func LogError(err error, message string) {
Log.WithFields(logrus.Fields{"error": err.Error()}).Warnln(message)
Log.WithError(err).Errorln(message)
}
4 changes: 2 additions & 2 deletions pkg/server/ecsCredentialsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func getCredentialHandler(region string) func(http.ResponseWriter, *http.Request
return func(w http.ResponseWriter, r *http.Request) {
var client, err = creds.GetClient()
if err != nil {
logging.Log.Error(err)
logging.LogError(err, "error getting credentials")
util.WriteError(w, err.Error(), http.StatusBadRequest)
return
}
assume, err := parseAssumeRoleQuery(r)
if err != nil {
logging.Log.Error(err)
logging.LogError(err, "error parsing assume role query")
util.WriteError(w, err.Error(), http.StatusBadRequest)
return
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func Run(host string, port int, role, region string, shutdown chan os.Signal) er

ln, err := net.Listen("tcp", listenAddr)
if err != nil {
logging.Log.Errorf("listen failed: %v", err)
logging.LogError(err, "listen failed")
return err
}

go func() {
if err := srv.Serve(ln); err != nil {
logging.Log.Errorf("server failed: %v", err)
logging.LogError(err, "server failed")
}
}()

Expand Down

0 comments on commit 50ae0fa

Please sign in to comment.