replacements are now saved in a map
Dieser Commit ist enthalten in:
Ursprung
0a6bdecf5d
Commit
926788a128
|
@ -19,6 +19,11 @@ import (
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var replacements = map[string]string{
|
||||||
|
"-": "_",
|
||||||
|
" ": "_",
|
||||||
|
}
|
||||||
|
|
||||||
const defaultJournalDPrio = journal.PriNotice
|
const defaultJournalDPrio = journal.PriNotice
|
||||||
|
|
||||||
func binaryFmt(p []byte) bool {
|
func binaryFmt(p []byte) bool {
|
||||||
|
@ -66,6 +71,14 @@ func levelToJPrio(zLevel string) journal.Priority {
|
||||||
return defaultJournalDPrio
|
return defaultJournalDPrio
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func replace(input string) (output string) {
|
||||||
|
output = input
|
||||||
|
for key, value := range replacements {
|
||||||
|
output = strings.ReplaceAll(output, key, value)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (w journalWriter) Write(p []byte) (n int, err error) {
|
func (w journalWriter) Write(p []byte) (n int, err error) {
|
||||||
var event map[string]interface{}
|
var event map[string]interface{}
|
||||||
origPLen := len(p)
|
origPLen := len(p)
|
||||||
|
@ -87,7 +100,7 @@ func (w journalWriter) Write(p []byte) (n int, err error) {
|
||||||
|
|
||||||
msg := ""
|
msg := ""
|
||||||
for key, value := range event {
|
for key, value := range event {
|
||||||
jKey := strings.ToUpper(key)
|
jKey := replace(strings.ToUpper(key))
|
||||||
switch key {
|
switch key {
|
||||||
case zerolog.LevelFieldName, zerolog.TimestampFieldName:
|
case zerolog.LevelFieldName, zerolog.TimestampFieldName:
|
||||||
continue
|
continue
|
||||||
|
|
Laden…
In neuem Issue referenzieren