-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.go
More file actions
50 lines (43 loc) · 1.4 KB
/
config.go
File metadata and controls
50 lines (43 loc) · 1.4 KB
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
package fluentio
import "github.com/fluent/fluent-logger-golang/fluent"
// Config is used to configure the Writer.
type Config struct {
fluentConfig *fluent.Config
basicConfig *BasicConfig
tag string
discardWritesAfterClose bool
}
// BasicConfig is used to configure the Writer with a basic configuration.
type BasicConfig struct {
FluentHost string
FluentPort int
Milliseconds bool
}
// WithBasicConfig returns a function that can be used to configure the Writer with a basic configuration.
func WithBasicConfig(host string, port int, milliseconds bool) func(*Config) {
return func(c *Config) {
c.basicConfig = &BasicConfig{
FluentHost: host,
FluentPort: port,
Milliseconds: milliseconds,
}
}
}
// WithFluentConfig returns a function that can be used to configure the Writer with the standard fluent-logger-golang configuration.
func WithFluentConfig(config *fluent.Config) func(*Config) {
return func(c *Config) {
c.fluentConfig = config
}
}
// WithTag returns a function that can be used to configure the Writer with a tag.
func WithTag(tag string) func(*Config) {
return func(c *Config) {
c.tag = tag
}
}
// WithDiscardWritesAfterClose returns a function that can be used to configure the Writer to discard writes after Close()
func WithDiscardWritesAfterClose() func(*Config) {
return func(c *Config) {
c.discardWritesAfterClose = true
}
}