Skip to content

Commit

Permalink
feat(basic config): add milliseconds precision
Browse files Browse the repository at this point in the history
  • Loading branch information
gllm-dev committed Apr 10, 2023
1 parent 7097fe5 commit 666e630
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
12 changes: 7 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ type Config struct {

// BasicConfig is used to configure the Writer with a basic configuration.
type BasicConfig struct {
FluentHost string
FluentPort int
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) func(*Config) {
func WithBasicConfig(host string, port int, milliseconds bool) func(*Config) {
return func(c *Config) {
c.basicConfig = &BasicConfig{
FluentHost: host,
FluentPort: port,
FluentHost: host,
FluentPort: port,
Milliseconds: milliseconds,
}
}
}
Expand Down
18 changes: 5 additions & 13 deletions fluent.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,16 @@ func New(opts ...func(config *Config)) (*Writer, error) {
opt(config)
}

if config == nil {
return nil, ErrNoConfigProvided
}

var cfg *fluent.Config

if config.basicConfig != nil {
cfg = &fluent.Config{
FluentHost: config.basicConfig.FluentHost,
FluentPort: config.basicConfig.FluentPort,
FluentHost: config.basicConfig.FluentHost,
FluentPort: config.basicConfig.FluentPort,
SubSecondPrecision: config.basicConfig.Milliseconds,
}
}

if config.fluentConfig != nil {
} else if config.fluentConfig != nil {
cfg = config.fluentConfig
}

if cfg == nil {
} else {
return nil, ErrNoConfigProvided
}

Expand Down

0 comments on commit 666e630

Please sign in to comment.