diff --git a/internal/log/log.go b/internal/log/log.go index 31c183e9d7274d35ad2d70c7c1f5418586bc5a2d..8d2583cdabb0a6d4184137e25e36bf253d86d858 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -6,12 +6,16 @@ import ( "os" "runtime/debug" "sync" + "sync/atomic" "time" "gopkg.in/natefinch/lumberjack.v2" ) -var initOnce sync.Once +var ( + initOnce sync.Once + initialized atomic.Bool +) func Init(logFile string, debug bool) { initOnce.Do(func() { @@ -34,9 +38,14 @@ func Init(logFile string, debug bool) { }) slog.SetDefault(slog.New(logger)) + initialized.Store(true) }) } +func IsInitialized() bool { + return initialized.Load() +} + func RecoverPanic(name string, cleanup func()) { if r := recover(); r != nil { // Create a timestamped panic log file