/
logging.go
48 lines (40 loc) · 1.31 KB
/
logging.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
package caddy
import (
"encoding/json"
"fmt"
"io"
"time"
"go.uber.org/zap/zapcore"
)
type Logging struct {
Sink *StandardLibLog `json:"sink,omitempty"`
Logs map[string]*CustomLog `json:"logs,omitempty"`
writerKeys []string
}
type StandardLibLog struct {
WriterRaw json.RawMessage `json:"writer,omitempty" caddy:"namespace=caddy.logging.writers inline_key=output"`
write io.WriteCloser
}
type CustomLog struct {
WriteRaw json.RawMessage `json:"writer,omitempty" caddy:"namespace=caddy.logging.writers inline_key=output"`
EncoderRaw json.RawMessage `json:"encoder,omitempty" caddy:"namespace=caddy.logging.encoders inline_key=format"`
Level string `json:"level,omitempty"`
Sampling *LogSampling `json:"sampling,omitempty"`
Include []string `json:"include,omitempty"`
Exclude []string `json:"encoding,omitempty"`
writerOpener WriterOpener
writer io.WriteCloser
encoder zapcore.Encoder
levelEnable zapcore.LevelEnabler
core zapcore.Core
}
type LogSampling struct {
Interval time.Duration `json:"interval,omitempty"`
First int `json:first,omitempty"`
Thereafter int `json:thereafter,omitempty"`
}
type WriterOpener interface {
fmt.Stringer
WriterKey() string
OpenWriter() (io.WriteCloser, error)
}