Refactor logging

This commit is contained in:
Alexander
2026-05-07 16:50:40 +02:00
parent fb2e4b9107
commit 3d111f9008
14 changed files with 683 additions and 58 deletions
+20
View File
@@ -10,12 +10,24 @@ import (
type Config struct {
Server ServerConfig `yaml:"server"`
Database DatabaseConfig `yaml:"database"`
Logging LoggingConfig `yaml:"logging"`
Metrics MetricsConfig `yaml:"metrics"`
}
type ServerConfig struct {
Port int `yaml:"port"`
}
type LoggingConfig struct {
Level string `yaml:"level"`
Format string `yaml:"format"` // "json" or "console"
}
type MetricsConfig struct {
Enabled bool `yaml:"enabled"`
Port int `yaml:"port"`
}
type DatabaseConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
@@ -35,6 +47,14 @@ func Load(path string) (*Config, error) {
Port: 5432,
SSLMode: "disable",
},
Logging: LoggingConfig{
Level: "info",
Format: "json",
},
Metrics: MetricsConfig{
Enabled: true,
Port: 9090,
},
}
if path == "" {