Skip to content

Commit

Permalink
Merge pull request #9 from Roshick/handleroptions
Browse files Browse the repository at this point in the history
Rename handleroptions.Config
  • Loading branch information
Roshick authored Dec 13, 2023
2 parents 677a1c2 + f3d1356 commit 691175a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/handleroptions/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ const (

type TimestampTransformer func(time.Time) time.Time

type DefaultConfigImpl struct {
type Config struct {
vLogLevel slog.Level
vLogAttributeKeyMappings map[string]string
vTimestampTransformer TimestampTransformer
}

func NewDefaultConfig() *DefaultConfigImpl {
return &DefaultConfigImpl{
func NewDefaultConfig() *Config {
return &Config{
vTimestampTransformer: func(timestamp time.Time) time.Time {
return timestamp.UTC()
},
}
}

func (c *DefaultConfigImpl) SetTimestampTransformer(transformer TimestampTransformer) {
func (c *Config) SetTimestampTransformer(transformer TimestampTransformer) {
c.vTimestampTransformer = transformer
}

func (c *DefaultConfigImpl) HandlerOptions() *slog.HandlerOptions {
func (c *Config) HandlerOptions() *slog.HandlerOptions {
replaceAttr := func(_ []string, attr slog.Attr) slog.Attr {
if attr.Key == slog.TimeKey {
attr.Value = slog.TimeValue(c.vTimestampTransformer(attr.Value.Time()))
Expand All @@ -57,7 +57,7 @@ func (c *DefaultConfigImpl) HandlerOptions() *slog.HandlerOptions {
}
}

func (c *DefaultConfigImpl) ConfigItems() []auconfigapi.ConfigItem {
func (c *Config) ConfigItems() []auconfigapi.ConfigItem {
return []auconfigapi.ConfigItem{
{
Key: DefaultKeyLogLevel,
Expand All @@ -76,7 +76,7 @@ func (c *DefaultConfigImpl) ConfigItems() []auconfigapi.ConfigItem {
}
}

func (c *DefaultConfigImpl) ObtainValues(getter func(string) string) error {
func (c *Config) ObtainValues(getter func(string) string) error {
if vLogLevel, err := level.ParseLogLevel(getter(DefaultKeyLogLevel)); err != nil {
return err
} else {
Expand Down

0 comments on commit 691175a

Please sign in to comment.