Skip to content

Commit

Permalink
INT - fix logger config max file size (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollins-axway authored Jun 27, 2024
1 parent f8aabac commit d784b3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/util/log/loggerconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (b *LoggerConfig) Apply() error {
if err := b.validate0orGreater("log.metricfile.cleanbackupsevery", b.metricCfg.MaxAge); err != nil {
return err
}
b.metricCfg.MaxSize = ConvertMaxSize(b.metricCfg.MaxSize)
}

if b.usageEnabled {
Expand All @@ -92,6 +93,7 @@ func (b *LoggerConfig) Apply() error {
if err := b.validate0orGreater("log.usagefile.cleanbackupsevery", b.usageCfg.MaxAge); err != nil {
return err
}
b.usageCfg.MaxSize = ConvertMaxSize(b.usageCfg.MaxSize)
}

// update the log logger
Expand Down Expand Up @@ -249,7 +251,7 @@ func (b *LoggerConfig) validate0orGreater(path string, maxBackups int) error {
func (b *LoggerConfig) MaxSize(maxSize int) *LoggerConfig {
if b.err == nil {
b.err = b.validateSize("log.file.rotateeverybytes", maxSize)
b.cfg.MaxSize = int(float64(maxSize) / 1024 / 1024)
b.cfg.MaxSize = ConvertMaxSize(maxSize)
}
return b
}
Expand Down Expand Up @@ -331,3 +333,8 @@ func (b *LoggerConfig) MaxUsageAge(maxAge int) *LoggerConfig {
}
return b
}

// ConvertMaxSize - takes max size in bytes and returns in megabytes for the rotate file hook
func ConvertMaxSize(maxSize int) int {
return int(maxSize / 1024 / 1024)
}

0 comments on commit d784b3e

Please sign in to comment.