feat(logs): by default, log server activity to a file.

This commit is contained in:
Houmgaor
2025-11-18 00:18:32 +01:00
parent 7aafc71dcc
commit 9a47a876eb
12 changed files with 132 additions and 16 deletions

View File

@@ -27,6 +27,7 @@ type Config struct {
DevModeOptions DevModeOptions
GameplayOptions GameplayOptions
Logging Logging
Discord Discord
Commands []Command
Courses []Course
@@ -73,6 +74,16 @@ type GameplayOptions struct {
DailyQuestAllowance uint32 // Number of Daily Quests to allow daily
}
// Logging holds the logging configuration.
type Logging struct {
LogToFile bool // Enable/disable file logging (default: true)
LogFilePath string // File path for logs (default: "logs/erupe.log")
LogMaxSize int // Max size in MB before rotation (default: 100)
LogMaxBackups int // Number of old log files to keep (default: 3)
LogMaxAge int // Max days to retain old logs (default: 28)
LogCompress bool // Compress rotated logs (default: true)
}
// Discord holds the discord integration config.
type Discord struct {
Enabled bool
@@ -197,6 +208,15 @@ func LoadConfig() (*Config, error) {
OutputDir: "savedata",
})
viper.SetDefault("Logging", Logging{
LogToFile: true,
LogFilePath: "logs/erupe.log",
LogMaxSize: 100,
LogMaxBackups: 3,
LogMaxAge: 28,
LogCompress: true,
})
err := viper.ReadInConfig()
if err != nil {
return nil, err