Skip to content

Commit 5e86735

Browse files
committed
Improvements after testing
1 parent 9f2be64 commit 5e86735

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

internal/http/log.go

+23-20
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,30 @@ func (lt *LoggingTransport) RoundTrip(req *http.Request) (*http.Response, error)
1919
}
2020

2121
start := time.Now()
22-
2322
resp, err := rt.RoundTrip(req)
24-
switch {
25-
case err != nil:
26-
slog.Info("HTTP error",
27-
slog.String("method", req.Method),
28-
slog.String("url", req.URL.String()),
29-
slog.Duration("duration", time.Since(start)),
30-
slog.String("error", err.Error()))
31-
case resp.StatusCode < 300:
32-
slog.Info("HTTP error response",
33-
slog.String("method", req.Method),
34-
slog.String("url", req.URL.String()),
35-
slog.Duration("duration", time.Since(start)),
36-
slog.String("status", resp.Status))
37-
default:
38-
slog.Debug("HTTP success response",
39-
slog.String("method", req.Method),
40-
slog.String("url", req.URL.String()),
41-
slog.Duration("duration", time.Since(start)),
42-
slog.String("status", resp.Status))
23+
24+
// don't log health checks
25+
if req.URL.Path != "/v1/sys/health" {
26+
switch {
27+
case err != nil:
28+
slog.Info("HTTP error",
29+
slog.String("method", req.Method),
30+
slog.String("url", req.URL.String()),
31+
slog.Duration("duration", time.Since(start)),
32+
slog.String("error", err.Error()))
33+
case resp.StatusCode >= 300:
34+
slog.Info("HTTP error response",
35+
slog.String("method", req.Method),
36+
slog.String("url", req.URL.String()),
37+
slog.Duration("duration", time.Since(start)),
38+
slog.String("status", resp.Status))
39+
default:
40+
slog.Debug("HTTP success response",
41+
slog.String("method", req.Method),
42+
slog.String("url", req.URL.String()),
43+
slog.Duration("duration", time.Since(start)),
44+
slog.String("status", resp.Status))
45+
}
4346
}
4447

4548
return resp, err

internal/keystore/vault/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,6 @@ func (c *Config) Clone() *Config {
249249
PrivateKey: c.PrivateKey,
250250
Certificate: c.Certificate,
251251
CAPath: c.CAPath,
252+
Verbose: c.Verbose,
252253
}
253254
}

internal/keystore/vault/vault.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func Connect(ctx context.Context, c *Config) (*Store, error) {
142142

143143
// log authentication events
144144
lastAuthSuccess := false
145-
authenticate = func(ctx context.Context) (*vaultapi.Secret, error) {
145+
authenticateLogged := func(ctx context.Context) (*vaultapi.Secret, error) {
146146
secret, err := authenticate(ctx)
147147
if err != nil {
148148
if lastAuthSuccess {
@@ -164,7 +164,7 @@ func Connect(ctx context.Context, c *Config) (*Store, error) {
164164
return secret, err
165165
}
166166

167-
auth, err := authenticate(ctx)
167+
auth, err := authenticateLogged(ctx)
168168
if err != nil {
169169
return nil, err
170170
}

0 commit comments

Comments
 (0)