implement panic log for gateway and launcher

add file logger to gateway

ref issue: #1734

Signed-off-by: Cytown <cytown@gmail.com>
This commit is contained in:
Cytown
2026-03-23 15:40:17 +08:00
parent cff9065084
commit df17684dd4
10 changed files with 163 additions and 7 deletions
+17 -1
View File
@@ -47,6 +47,10 @@ const (
serviceShutdownTimeout = 30 * time.Second
providerReloadTimeout = 30 * time.Second
gracefulShutdownTimeout = 15 * time.Second
logPath = "logs"
panicFile = "gateway_panic.log"
logFile = "gateway.log"
)
type services struct {
@@ -79,7 +83,19 @@ func (p *startupBlockedProvider) GetDefaultModel() string {
}
// Run starts the gateway runtime using the configuration loaded from configPath.
func Run(debug bool, configPath string, allowEmptyStartup bool) error {
func Run(debug bool, homePath, configPath string, allowEmptyStartup bool) error {
panicPath := filepath.Join(homePath, logPath, panicFile)
panicFunc, err := logger.InitPanic(panicPath)
if err != nil {
return fmt.Errorf("error initializing panic log: %w", err)
}
defer panicFunc()
if err = logger.EnableFileLogging(filepath.Join(homePath, logPath, logFile)); err != nil {
panic(fmt.Sprintf("error enabling file logging: %v", err))
}
defer logger.DisableFileLogging()
cfg, err := config.LoadConfig(configPath)
if err != nil {
return fmt.Errorf("error loading config: %w", err)