mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
The server module named github.com/hanzoai/team/server/v8 — a path that resolves to the retired workspace's repository, not this one — while server/public still published github.com/mattermost/mattermost/server/public. Both are github.com/hanzoteam/server/... now, which is where this code actually lives. That second half is what made the binary unbootable. Upstream's public path stayed claimed by upstream, mattermost-plugin-ai imported it, and the build linked public/model twice; public/plugin's gob.Register then ran twice under one name and panicked at init, before main. Reverting the rename traded the brand for a working binary. Rebranding the plugin alongside it needs no such trade: the agents fork is github.com/hanzoteam/agents/v2 against our public module, so no module named mattermost/mattermost is in the graph at all. Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and it is ours.
82 lines
1.8 KiB
Go
82 lines
1.8 KiB
Go
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
|
// See License for license information.
|
|
|
|
package logger
|
|
|
|
import (
|
|
"fmt"
|
|
"maps"
|
|
"time"
|
|
|
|
"github.com/hanzoteam/server/server/public/pluginapi/experimental/common"
|
|
)
|
|
|
|
type defaultLogger struct {
|
|
logContext LogContext
|
|
logAPI common.LogAPI
|
|
}
|
|
|
|
/*
|
|
New creates a new logger.
|
|
|
|
- api: LogAPI implementation
|
|
*/
|
|
func New(api common.LogAPI) Logger {
|
|
l := &defaultLogger{
|
|
logAPI: api,
|
|
}
|
|
return l
|
|
}
|
|
|
|
func (l *defaultLogger) With(logContext LogContext) Logger {
|
|
newLogger := *l
|
|
if len(newLogger.logContext) == 0 {
|
|
newLogger.logContext = map[string]any{}
|
|
}
|
|
maps.Copy(newLogger.logContext, logContext)
|
|
return &newLogger
|
|
}
|
|
|
|
func (l *defaultLogger) WithError(err error) Logger {
|
|
newLogger := *l
|
|
if len(newLogger.logContext) == 0 {
|
|
newLogger.logContext = map[string]any{}
|
|
}
|
|
newLogger.logContext[ErrorKey] = err.Error()
|
|
return &newLogger
|
|
}
|
|
|
|
func (l *defaultLogger) Context() LogContext {
|
|
return l.logContext
|
|
}
|
|
|
|
func (l *defaultLogger) Timed() Logger {
|
|
return l.With(LogContext{
|
|
timed: time.Now(),
|
|
})
|
|
}
|
|
|
|
func (l *defaultLogger) Debugf(format string, args ...any) {
|
|
measure(l.logContext)
|
|
message := fmt.Sprintf(format, args...)
|
|
l.logAPI.LogDebug(message, toKeyValuePairs(l.logContext)...)
|
|
}
|
|
|
|
func (l *defaultLogger) Errorf(format string, args ...any) {
|
|
measure(l.logContext)
|
|
message := fmt.Sprintf(format, args...)
|
|
l.logAPI.LogError(message, toKeyValuePairs(l.logContext)...)
|
|
}
|
|
|
|
func (l *defaultLogger) Infof(format string, args ...any) {
|
|
measure(l.logContext)
|
|
message := fmt.Sprintf(format, args...)
|
|
l.logAPI.LogInfo(message, toKeyValuePairs(l.logContext)...)
|
|
}
|
|
|
|
func (l *defaultLogger) Warnf(format string, args ...any) {
|
|
measure(l.logContext)
|
|
message := fmt.Sprintf(format, args...)
|
|
l.logAPI.LogWarn(message, toKeyValuePairs(l.logContext)...)
|
|
}
|