mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 12:36:37 +08:00
Limit and split production logs
This commit is contained in:
@@ -255,9 +255,10 @@ func setDefaults(v *viper.Viper) {
|
||||
|
||||
v.SetDefault("secrets.jwt_secret", "")
|
||||
|
||||
v.SetDefault("logging.level", "info")
|
||||
v.SetDefault("logging.level", "warn")
|
||||
v.SetDefault("logging.format", "console")
|
||||
v.SetDefault("logging.max_size_mb", 100)
|
||||
v.SetDefault("logging.enable_rotation", true)
|
||||
v.SetDefault("logging.max_size_mb", 20)
|
||||
v.SetDefault("logging.max_age_days", 30)
|
||||
v.SetDefault("logging.max_backups", 10)
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ func TestLoadDefaults(t *testing.T) {
|
||||
if cfg.Database.Type != "auto" {
|
||||
t.Fatalf("expected default database type auto, got %q", cfg.Database.Type)
|
||||
}
|
||||
if cfg.Logging.Level != "warn" || !cfg.Logging.EnableRotation || cfg.Logging.MaxSizeMB != 20 {
|
||||
t.Fatalf("expected warn rotating logs by default, got level=%q rotation=%v max=%d", cfg.Logging.Level, cfg.Logging.EnableRotation, cfg.Logging.MaxSizeMB)
|
||||
}
|
||||
if cfg.Database.MaxOpenConns != defaultDatabaseMaxOpenConns {
|
||||
t.Fatalf("expected default MaxOpenConns %d, got %d", defaultDatabaseMaxOpenConns, cfg.Database.MaxOpenConns)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user