feat(logging): introduce centralized logging with custom format and Gin integration

- Implemented a global logger with structured formatting for consistent log output.
- Added support for rotating log files using Lumberjack.
- Integrated new logging functionality with Gin HTTP server for unified log handling.
- Replaced direct `log.Info` calls with `fmt.Printf` in non-critical paths to simplify core functionality.
This commit is contained in:
Luis Pater
2025-09-26 00:54:52 +08:00
parent 72325f792c
commit cf734f7e7b
20 changed files with 209 additions and 148 deletions

View File

@@ -23,6 +23,9 @@ type Config struct {
// Debug enables or disables debug-level logging and other debug features.
Debug bool `yaml:"debug" json:"debug"`
// LoggingToFile controls whether application logs are written to rotating files or stdout.
LoggingToFile bool `yaml:"logging-to-file" json:"logging-to-file"`
// ProxyURL is the URL of an optional proxy server to use for outbound requests.
ProxyURL string `yaml:"proxy-url" json:"proxy-url"`
@@ -202,6 +205,7 @@ func LoadConfig(configFile string) (*Config, error) {
// Unmarshal the YAML data into the Config struct.
var config Config
// Set defaults before unmarshal so that absent keys keep defaults.
config.LoggingToFile = true
config.GeminiWeb.Context = true
if err = yaml.Unmarshal(data, &config); err != nil {
return nil, fmt.Errorf("failed to parse config file: %w", err)