Skip to content

Commit

Permalink
Merge pull request #193 from projectsyn/log-vault-errors
Browse files Browse the repository at this point in the history
Log vault errors and messages
  • Loading branch information
bastjan authored Aug 10, 2021
2 parents 02bf041 + 834c944 commit 5a31238
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions vault/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func newBankVaultClient(deletionPolicy synv1alpha1.DeletionPolicy, log logr.Logg

client, err := vault.NewClientFromConfig(&api.Config{
Address: os.Getenv(api.EnvVaultAddress),
Logger: logAdapter{log},
}, vault.ClientRole("lieutenant-operator"))
if err != nil {
return nil, err
Expand Down
25 changes: 25 additions & 0 deletions vault/log_adapter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package vault

import (
"errors"

"github.com/go-logr/logr"
)

type logAdapter struct {
logr.Logger
}

var errLogAdapterLogError = errors.New("vault error log")

func (l logAdapter) Debug(msg string, keysAndValues ...interface{}) {
l.V(1).Info(msg, keysAndValues...)
}

func (l logAdapter) Warn(msg string, keysAndValues ...interface{}) {
l.Info("WARN: "+msg, keysAndValues...)
}

func (l logAdapter) Error(msg string, keysAndValues ...interface{}) {
l.Logger.Error(errLogAdapterLogError, msg, keysAndValues...)
}

0 comments on commit 5a31238

Please sign in to comment.