diff --git a/context.go b/context.go index 97778b0..3738077 100644 --- a/context.go +++ b/context.go @@ -14,7 +14,7 @@ func FromContext(ctx context.Context) *Logger { if logger, ok := ctx.Value(ContextKey).(*Logger); ok { return logger } - return defaultLogger + return Default() } type contextKey struct{ string } diff --git a/pkg.go b/pkg.go index eddc294..407478b 100644 --- a/pkg.go +++ b/pkg.go @@ -16,15 +16,14 @@ var ( // registry is a map of all registered lipgloss renderers. registry = sync.Map{} - initDefaultOnce sync.Once - // defaultLogger is the default global logger instance. - defaultLogger *Logger + defaultLoggerOnce sync.Once + defaultLogger *Logger ) // Default returns the default logger. The default logger comes with timestamp enabled. func Default() *Logger { - initDefaultOnce.Do(func() { + defaultLoggerOnce.Do(func() { if defaultLogger != nil { // already set via SetDefault. return