MM-22273 New auditing system (phase 1) (#13967)
* New auditing API outputting to syslog via TLS * New config section for specifying remote syslog server IP, port, and cert. * Legacy audit API retained for access history feature
Этот коммит содержится в:
43
vendor/github.com/wiggin77/merror/format.go
сгенерированный
поставляемый
Обычный файл
43
vendor/github.com/wiggin77/merror/format.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,43 @@
|
||||
package merror
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FormatterFunc is a function that converts a merror
|
||||
// to a string.
|
||||
type FormatterFunc func(merr *MError) string
|
||||
|
||||
// GlobalFormatter is the global merror formatter.
|
||||
// Set this to a custom formatter if desired.
|
||||
var GlobalFormatter = defaultFormatter
|
||||
|
||||
// defaultFormatter
|
||||
func defaultFormatter(merr *MError) string {
|
||||
count := 0
|
||||
overflow := 0
|
||||
|
||||
var format func(sb *strings.Builder, merr *MError, indent string)
|
||||
format = func(sb *strings.Builder, merr *MError, indent string) {
|
||||
count += merr.Len()
|
||||
overflow += merr.Overflow()
|
||||
|
||||
fmt.Fprintf(sb, "%sMError:\n", indent)
|
||||
for _, err := range merr.Errors() {
|
||||
if e, ok := err.(*MError); ok {
|
||||
format(sb, e, indent+" ")
|
||||
} else {
|
||||
fmt.Fprintf(sb, "%s%s\n", indent, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sb := &strings.Builder{}
|
||||
format(sb, merr, "")
|
||||
fmt.Fprintf(sb, "%d errors total.\n", count)
|
||||
if merr.overflow > 0 {
|
||||
fmt.Fprintf(sb, "%d errors truncated.\n", overflow)
|
||||
}
|
||||
return sb.String()
|
||||
}
|
||||
Ссылка в новой задаче
Block a user