1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-03 10:43:58 +02:00

feat(logger): implement structured log formatter gcp compliant (#1028)

* feat(logger): implement structured log formatter gcp compliant

* docs: add new gcp logging format
This commit is contained in:
Christopher Brookes 2022-11-05 13:20:57 +01:00 committed by GitHub
parent eaadb472f5
commit cfa4b596d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -434,6 +434,7 @@ imgproxy can report occurred errors to Bugsnag, Honeybadger and Sentry:
* `pretty`: _(default)_ colored human-readable format
* `structured`: machine-readable format
* `json`: JSON format
* `gcp`: Google Cloud Logging agent compliant
* `IMGPROXY_LOG_LEVEL`: the log level. The following levels are supported `error`, `warn`, `info` and `debug`. Default: `info`
imgproxy can send logs to syslog, but this feature is disabled by default. To enable it, set `IMGPROXY_SYSLOG_ENABLE` to `true`:

View File

@ -23,6 +23,13 @@ func Init() error {
logrus.SetFormatter(&structuredFormatter{})
case "json":
logrus.SetFormatter(&logrus.JSONFormatter{})
case "gcp":
logrus.SetFormatter(&logrus.JSONFormatter{
FieldMap: logrus.FieldMap{
"level": "severity",
"msg": "message",
},
})
default:
logrus.SetFormatter(newPrettyFormatter())
}