feat(config): add temporary logging for failed reloads

- Add tmpLogBuf and tmpLog fields to capture config loading logs
  - Flush temporary logs only when reload succeeds
  - Extract NewLogger function for creating custom loggers
  - Update State interface to include FlushTmpLog method
This commit is contained in:
yusing
2025-10-10 22:20:12 +08:00
parent 357ce38b18
commit 38c0419483
4 changed files with 34 additions and 9 deletions

View File

@@ -45,6 +45,9 @@ func Load() error {
notifyError("init", err)
}
SetState(state)
// flush temporary log
state.FlushTmpLog()
return nil
}
@@ -69,6 +72,9 @@ func Reload() gperr.Error {
return gperr.New(ansi.Warning("using last config")).With(err)
}
// flush temporary log
newState.FlushTmpLog()
// cancel all current subtasks -> wait
// -> replace config -> start new subtasks
GetState().Task().FinishAndWait(config.ErrConfigChanged)