Files
tasks/common/log/lazy_logger.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

71 lines
1.3 KiB
Go

package log
import (
"sync"
"github.com/hanzoai/tasks/common/log/tag"
)
var _ Logger = (*lazyLogger)(nil)
var _ WithLogger = (*lazyLogger)(nil)
type (
lazyLogger struct {
logger Logger
tagFn func() []tag.Tag
once sync.Once
}
)
func NewLazyLogger(logger Logger, tagFn func() []tag.Tag) *lazyLogger {
return &lazyLogger{
logger: logger,
tagFn: tagFn,
}
}
func (l *lazyLogger) Debug(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.Debug(msg, tags...)
}
func (l *lazyLogger) Info(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.Info(msg, tags...)
}
func (l *lazyLogger) Warn(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.Warn(msg, tags...)
}
func (l *lazyLogger) Error(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.Error(msg, tags...)
}
func (l *lazyLogger) DPanic(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.DPanic(msg, tags...)
}
func (l *lazyLogger) Panic(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.Panic(msg, tags...)
}
func (l *lazyLogger) Fatal(msg string, tags ...tag.Tag) {
l.once.Do(l.tagLogger)
l.logger.Fatal(msg, tags...)
}
func (l *lazyLogger) With(tags ...tag.Tag) Logger {
l.once.Do(l.tagLogger)
return With(l.logger, tags...)
}
func (l *lazyLogger) tagLogger() {
l.logger = With(l.logger, l.tagFn()...)
}