We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e62284f commit f821301Copy full SHA for f821301
main.go
@@ -99,10 +99,15 @@ func clearCache(cachePath string) {
99
100
func logJSON(msg string, fields map[string]string) {
101
entry := map[string]string{
102
- "msg": "[nginx-cache-sync] " + msg,
+ "msg": msg,
103
}
104
for k, v := range fields {
105
entry[k] = v
106
107
- _ = json.NewEncoder(os.Stdout).Encode(entry)
+ jsonBytes, err := json.Marshal(entry)
108
+ if err != nil {
109
+ fmt.Fprintf(os.Stdout, "[nginx-cache-sync] {\"msg\":\"failed to encode log: %s\"}\n", err.Error())
110
+ return
111
+ }
112
+ fmt.Fprintf(os.Stdout, "[nginx-cache-sync] %s\n", string(jsonBytes))
113
0 commit comments