File tree Expand file tree Collapse file tree 1 file changed +15
-23
lines changed
Expand file tree Collapse file tree 1 file changed +15
-23
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,6 @@ import (
2525 "github.com/GoogleCloudPlatform/cloud-sql-proxy/v2/cloudsql"
2626)
2727
28- const (
29- googLvlKey = "severity"
30- googMsgKey = "message"
31- googSourceKey = "sourceLocation"
32- googTimeKey = "timestamp"
33- )
34-
3528// StdLogger is the standard logger that distinguishes between info and error
3629// logs.
3730type StdLogger struct {
@@ -110,22 +103,21 @@ func NewStructuredLogger(quiet bool) cloudsql.Logger {
110103// replaceAttr remaps default Go logging keys to adhere to LogEntry format
111104// https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
112105func replaceAttr (groups []string , a slog.Attr ) slog.Attr {
113- if groups == nil {
114- if a .Key == slog .LevelKey {
115- a .Key = googLvlKey
116- return a
117- } else if a .Key == slog .MessageKey {
118- a .Key = googMsgKey
119- return a
120- } else if a .Key == slog .SourceKey {
121- a .Key = googSourceKey
122- return a
123- } else if a .Key == slog .TimeKey {
124- a .Key = googTimeKey
125- if a .Value .Kind () == slog .KindTime {
126- a .Value = slog .StringValue (a .Value .Time ().Format (time .RFC3339 ))
127- }
128- return a
106+ if groups != nil {
107+ return a
108+ }
109+
110+ switch a .Key {
111+ case slog .LevelKey :
112+ a .Key = "severity"
113+ case slog .MessageKey :
114+ a .Key = "message"
115+ case slog .SourceKey :
116+ a .Key = "sourceLocation"
117+ case slog .TimeKey :
118+ a .Key = "timestamp"
119+ if a .Value .Kind () == slog .KindTime {
120+ a .Value = slog .StringValue (a .Value .Time ().Format (time .RFC3339 ))
129121 }
130122 }
131123 return a
You can’t perform that action at this time.
0 commit comments