mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
71 lines
1.3 KiB
Go
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()...)
|
|
}
|