-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathformats.go
61 lines (56 loc) · 1.64 KB
/
formats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package log
type logFormatter interface {
formatterName() string
// doc is used to generate the formatter documentation.
doc() string
// formatEntry formats a logEntry into a newly allocated *buffer.
// The caller is responsible for calling putBuffer() afterwards.
formatEntry(entry logEntry) *buffer
}
var formats = map[string]string{
"crdb-v1": "v1",
"crdb-v1-count": "v1",
"crdb-v1-tty": "v1",
"crdb-v1-tty-count": "v1",
"crdb-v2": "v2",
"crdb-v2-tty": "v2",
"json": "json",
"json-compact": "json",
"json-fluent": "json",
"json-fluent-compact": "json",
}
var formatters = func() map[string]logFormatter {
m := make(map[string]logFormatter)
r := func(f logFormatter) {
m[f.formatterName()] = f
}
r(formatCrdbV1{})
r(formatCrdbV1WithCounter{})
r(formatCrdbV1TTY{})
r(formatCrdbV1TTYWithCounter{})
r(formatCrdbV2{})
r(formatCrdbV2TTY{})
r(formatFluentJSONCompact{})
r(formatFluentJSONFull{})
r(formatJSONCompact{})
r(formatJSONFull{})
return m
}()
// GetFormatterDocs returns the embedded documentation for all the
// supported formats.
func GetFormatterDocs() map[string]string {
m := make(map[string]string)
for fmtName, f := range formatters {
m[fmtName] = f.doc()
}
return m
}