Skip to content

Commit

Permalink
logging warning for page unacceptable page size only
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-morlier committed May 2, 2024
1 parent 0490926 commit 5cf8290
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,10 @@ func LoadConfig(fname string) (*Config, error) {

log.Root().SetHandler(log.LvlFilterHandler(logLvl, log.Root().GetHandler()))

log.Error("this is the page size", "ps", cfg.PageSize)
if cfg.PageSize == 0 {
cfg.PageSize = 4096
}
if cfg.PageSize > 65536 {
log.Warn("config: pragma page size miust be less than or equal to 65536, setting to largest possible value: 65536")
cfg.PageSize = 65536
}
if cfg.PageSize > 0 && (cfg.PageSize&(cfg.PageSize-1)) != 0 {
var bit int64 = 1
for cfg.PageSize > 0 {
cfg.PageSize >>= 1
bit <<= 1
}
val := bit >> 1
log.Warn(fmt.Sprintf("config: pragma page size miust be a power of two, setting size to: %v", val))
cfg.PageSize = val
if cfg.PageSize < 4096 || cfg.PageSize > 65536 || (cfg.PageSize&(cfg.PageSize-1)) != 0 {
log.Warn(fmt.Sprintf("config: invalid pragma page size of %v, setting to default of 4096", cfg.PageSize))
}

log.Error("This is the port", "p", cfg.Port)
if cfg.Port == 0 {
cfg.Port = 8000
}
Expand Down

0 comments on commit 5cf8290

Please sign in to comment.