fix: sécuriser shutdown, config par défaut et reconnexion socket

Co-authored-by: aider (openrouter/openai/gpt-5.3-codex) <aider@aider.chat>
This commit is contained in:
Jacquin Antoine
2026-02-25 21:44:40 +01:00
parent 617ecd2014
commit 6cd6c4c3b8
11 changed files with 394 additions and 56 deletions

View File

@ -3,7 +3,6 @@ package logging
import (
"encoding/json"
"fmt"
"log"
"os"
"strings"
@ -49,7 +48,8 @@ func NewServiceLogger(level string) *ServiceLogger {
// Log emits a structured log entry to stdout in JSON format
func (l *ServiceLogger) Log(component, level, message string, details map[string]string) {
if !l.isLogLevelEnabled(level) {
normalizedLevel := strings.ToLower(level)
if !l.isLogLevelEnabled(normalizedLevel) {
return
}
@ -58,7 +58,7 @@ func (l *ServiceLogger) Log(component, level, message string, details map[string
defer l.mutex.Unlock()
serviceLog := api.ServiceLog{
Level: level,
Level: normalizedLevel,
Component: component,
Message: message,
Details: details,
@ -67,40 +67,32 @@ func (l *ServiceLogger) Log(component, level, message string, details map[string
jsonData, err := l.formatter(serviceLog)
if err != nil {
// Fallback to simple logging if JSON formatting fails
fmt.Printf(`{"timestamp":%d,"level":"ERROR","component":"logging","message":"%s","original_message":"%s"}`,
l.out.Printf(`{"timestamp":%d,"level":"ERROR","component":"logging","message":"%s","original_message":"%s"}`+"\n",
time.Now().UnixNano(), err.Error(), message)
return
}
fmt.Println(string(jsonData))
l.out.Println(string(jsonData))
}
// Debug logs a debug level entry
func (l *ServiceLogger) Debug(component, message string, details map[string]string) {
if l.isLogLevelEnabled("debug") {
l.Log(component, "DEBUG", message, details)
}
l.Log(component, "debug", message, details)
}
// Info logs an info level entry
func (l *ServiceLogger) Info(component, message string, details map[string]string) {
if l.isLogLevelEnabled("info") {
l.Log(component, "INFO", message, details)
}
l.Log(component, "info", message, details)
}
// Warn logs a warning level entry
func (l *ServiceLogger) Warn(component, message string, details map[string]string) {
if l.isLogLevelEnabled("warn") {
l.Log(component, "WARN", message, details)
}
l.Log(component, "warn", message, details)
}
// Error logs an error level entry
func (l *ServiceLogger) Error(component, message string, details map[string]string) {
if l.isLogLevelEnabled("error") {
l.Log(component, "ERROR", message, details)
}
l.Log(component, "error", message, details)
}
// isLogLevelEnabled checks if a log level should be emitted based on configured level