Pass a logger instead of embedding on job (#24650)
* pass a logger instead of embedding on job * leverage mlog.Millis * use worker logger with HandleJobPanic * rely on existing LogClone instead * guard Job.LogClone against nil Job * s/workername/worker_name * Revert "rely on existing LogClone instead" This reverts commit 17303cbac90d4b01815abca1309b78b97de368fb. * Revert "guard Job.LogClone against nil Job" This reverts commit f1ae22dee58d76f084582857830ffe8d4c546d7e.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
aa172294bd
Коммит
47bfa2b66b
@@ -5,9 +5,6 @@ package model
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -82,8 +79,6 @@ type Job struct {
|
||||
Status string `json:"status"`
|
||||
Progress int64 `json:"progress"`
|
||||
Data StringMap `json:"data"`
|
||||
|
||||
Logger *mlog.Logger `json:"-"`
|
||||
}
|
||||
|
||||
func (j *Job) Auditable() map[string]interface{} {
|
||||
@@ -124,16 +119,6 @@ func (j *Job) IsValid() *AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
// InitLogger attaches an annotated logger to a Job.
|
||||
// It should always be called after creating a new Job to ensure `Job.Logger` it set.
|
||||
func (j *Job) InitLogger(logger mlog.LoggerIFace) {
|
||||
j.Logger = logger.With(
|
||||
mlog.String("job_id", j.Id),
|
||||
mlog.String("job_type", j.Type),
|
||||
mlog.String("create_at", time.UnixMilli(j.CreateAt).String()),
|
||||
)
|
||||
}
|
||||
|
||||
func (j *Job) LogClone() any {
|
||||
return j.Auditable()
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user