mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00: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
2 changed files with 4 additions and 37 deletions
|
@ -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 (
|
||||
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")
|
||||
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. "+
|
||||
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")
|
||||
loggerOutput = flag.String("loggerOutput", "stderr", "Output for the logs. Supported values: stderr, stdout")
|
||||
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")
|
||||
disableTimestamps = flag.Bool("loggerDisableTimestamps", false, "Whether to disable writing timestamps in logs")
|
||||
|
||||
|
|
Loading…
Reference in a new issue