Skip to content

Commit

Permalink
refactor(config)!: remove InitDefaults method
Browse files Browse the repository at this point in the history
  • Loading branch information
iagapie committed Nov 7, 2024
1 parent b9e3773 commit 1643880
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Config struct {
FileLogger *FileLoggerConfig `json:"fileLogger,omitempty" yaml:"fileLogger,omitempty"`
}

func (cfg *Config) InitDefaults() {
func (cfg *Config) setDefaults() {
if cfg.Mode == "" {
if color.NoColor {
cfg.Mode = production
Expand All @@ -62,7 +62,7 @@ func (cfg *Config) InitDefaults() {
cfg.ErrorOutput = []string{"stderr"}
}
if cfg.FileLogger != nil {
cfg.FileLogger.InitDefaults()
cfg.FileLogger.setDefaults()
}
}

Expand Down Expand Up @@ -98,7 +98,7 @@ type FileLoggerConfig struct {
Compress bool `json:"compress,omitempty" yaml:"compress,omitempty"`
}

func (cfg *FileLoggerConfig) InitDefaults() {
func (cfg *FileLoggerConfig) setDefaults() {
if cfg.MaxSize == 0 {
cfg.MaxSize = 100
}
Expand Down
2 changes: 2 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func NewSlog(logger *zap.Logger) *slog.Logger {
}

func NewZap(cfg Config) (*zap.Logger, error) {
cfg.setDefaults()

var zCfg zap.Config
switch cfg.Mode {
case off, none:
Expand Down

0 comments on commit 1643880

Please sign in to comment.