Change summary
internal/log/log.go | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
Detailed changes
@@ -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