mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 23:39:48 +01:00
lib/logger: follow-up for 72f8fce107
- Document the change at docs/CHANELOG.md - Log fatal errors if the -loggerJSONFields contains unexpected values - Rename -loggerJsonFields to -loggerJSONFields for the sake of consistency naming commonly used in Go Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2348
This commit is contained in:
parent
cffd2f79a1
commit
2fad03d85e
@ -1,32 +0,0 @@
|
|||||||
package logger
|
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
var (
|
|
||||||
fieldTs = "ts"
|
|
||||||
fieldLevel = "level"
|
|
||||||
fieldCaller = "caller"
|
|
||||||
fieldMsg = "msg"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setLoggerJSONFields() {
|
|
||||||
fields := strings.Split(*loggerJSONFields, ",")
|
|
||||||
for _, f := range fields {
|
|
||||||
v := strings.Split(strings.TrimSpace(f), ":")
|
|
||||||
if len(v) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
old, new := v[0], v[1]
|
|
||||||
switch old {
|
|
||||||
case "ts":
|
|
||||||
fieldTs = new
|
|
||||||
case "level":
|
|
||||||
fieldLevel = new
|
|
||||||
case "caller":
|
|
||||||
fieldCaller = new
|
|
||||||
case "msg":
|
|
||||||
fieldMsg = new
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,11 +17,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
loggerLevel = flag.String("loggerLevel", "INFO", "Minimum level of errors to log. Possible values: INFO, WARN, ERROR, FATAL, PANIC")
|
loggerLevel = flag.String("loggerLevel", "INFO", "Minimum level of errors to log. Possible values: INFO, WARN, ERROR, FATAL, PANIC")
|
||||||
loggerFormat = flag.String("loggerFormat", "default", "Format for logs. Possible values: default, json")
|
loggerFormat = flag.String("loggerFormat", "default", "Format for logs. Possible values: default, json")
|
||||||
loggerOutput = flag.String("loggerOutput", "stderr", "Output for the logs. Supported values: stderr, stdout")
|
loggerOutput = flag.String("loggerOutput", "stderr", "Output for the logs. Supported values: stderr, stdout")
|
||||||
loggerJSONFields = flag.String("loggerJsonFields", "", `Allows renaming fields in JSON formatted logs. Example: "ts:timestamp,msg:message" renames "ts" to "timestamp" and "msg" to "message"`)
|
loggerTimezone = flag.String("loggerTimezone", "UTC", "Timezone to use for timestamps in logs. Timezone must be a valid IANA Time Zone. "+
|
||||||
loggerTimezone = flag.String("loggerTimezone", "UTC", "Timezone to use for timestamps in logs. Timezone must be a valid IANA Time Zone. "+
|
|
||||||
"For example: America/New_York, Europe/Berlin, Etc/GMT+3 or Local")
|
"For example: America/New_York, Europe/Berlin, Etc/GMT+3 or Local")
|
||||||
disableTimestamps = flag.Bool("loggerDisableTimestamps", false, "Whether to disable writing timestamps in logs")
|
disableTimestamps = flag.Bool("loggerDisableTimestamps", false, "Whether to disable writing timestamps in logs")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user