mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-28 00:24:19 +00:00
fix(logger): prevent nil-deref panic in migrate/setting CLI paths
The package-level logger is nil until InitLogger runs, which only happens in runWebServer. The migrate and setting subcommands log without initializing it; PR #5520 added a logger.Info on a success path in MigrationRestoreVisionFlow, so 'x-ui migrate' segfaults on installs with a VLESS inbound needing Vision-flow restoration. Initialize logger to a usable default at package load so no code path can nil-deref it, and set up the dual backend in migrateDb so migration steps are logged like runWebServer. Fixes #5581
This commit is contained in:
@@ -29,7 +29,9 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
logger *logging.Logger
|
||||
// Initialized to a usable default so logging never nil-derefs before InitLogger
|
||||
// runs — the "migrate" and "setting" CLI subcommands log without calling it.
|
||||
logger = logging.MustGetLogger("x-ui")
|
||||
fileRotate *lumberjack.Logger // nil when file backend disabled
|
||||
|
||||
// logBuffer maintains recent log entries in memory for web UI retrieval;
|
||||
|
||||
Reference in New Issue
Block a user