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).
77 lines
1.4 KiB
Go
77 lines
1.4 KiB
Go
package log
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"go.temporal.io/sdk/log"
|
|
"github.com/hanzoai/tasks/common/log/tag"
|
|
)
|
|
|
|
const (
|
|
extraSkipForSdkLogger = 1
|
|
noValue = "no value"
|
|
)
|
|
|
|
type SdkLogger struct {
|
|
logger Logger
|
|
}
|
|
|
|
var _ log.Logger = (*SdkLogger)(nil)
|
|
|
|
func NewSdkLogger(logger Logger) *SdkLogger {
|
|
if sl, ok := logger.(SkipLogger); ok {
|
|
logger = sl.Skip(extraSkipForSdkLogger)
|
|
}
|
|
|
|
return &SdkLogger{
|
|
logger: logger,
|
|
}
|
|
}
|
|
|
|
func (l *SdkLogger) tags(keyvals []any) []tag.Tag {
|
|
var tags []tag.Tag
|
|
for i := 0; i < len(keyvals); i++ {
|
|
if t, keyvalIsTag := keyvals[i].(tag.Tag); keyvalIsTag {
|
|
tags = append(tags, t)
|
|
continue
|
|
}
|
|
|
|
key, keyIsString := keyvals[i].(string)
|
|
if !keyIsString {
|
|
key = fmt.Sprintf("%v", keyvals[i])
|
|
}
|
|
var val any
|
|
if i+1 == len(keyvals) {
|
|
val = noValue
|
|
} else {
|
|
val = keyvals[i+1]
|
|
i++
|
|
}
|
|
|
|
tags = append(tags, tag.Any(key, val))
|
|
}
|
|
|
|
return tags
|
|
}
|
|
|
|
func (l *SdkLogger) Debug(msg string, keyvals ...any) {
|
|
l.logger.Debug(msg, l.tags(keyvals)...)
|
|
}
|
|
|
|
func (l *SdkLogger) Info(msg string, keyvals ...any) {
|
|
l.logger.Info(msg, l.tags(keyvals)...)
|
|
}
|
|
|
|
func (l *SdkLogger) Warn(msg string, keyvals ...any) {
|
|
l.logger.Warn(msg, l.tags(keyvals)...)
|
|
}
|
|
|
|
func (l *SdkLogger) Error(msg string, keyvals ...any) {
|
|
l.logger.Error(msg, l.tags(keyvals)...)
|
|
}
|
|
|
|
func (l *SdkLogger) With(keyvals ...any) log.Logger {
|
|
return NewSdkLogger(
|
|
With(l.logger, l.tags(keyvals)...))
|
|
}
|