MM-45193 Use context for channel logging (#20575)

Этот коммит содержится в:
Tim Scheuermann
2022-07-14 12:01:29 +03:00
коммит произвёл GitHub
родитель 5f4da3f308
Коммит 6dc897b04f
122 изменённых файлов: 2133 добавлений и 2082 удалений

Просмотреть файл

@@ -38,9 +38,10 @@ func NewContext(ctx context.Context, requestId, ipAddress, path, userAgent, acce
}
}
func EmptyContext() *Context {
func EmptyContext(logger mlog.LoggerIFace) *Context {
return &Context{
t: i18n.T,
logger: logger,
context: context.Background(),
}
}
@@ -116,3 +117,27 @@ func (c *Context) SetAppError(err *model.AppError) {
func (c *Context) AppError() *model.AppError {
return c.err
}
type CTX interface {
T(string, ...interface{}) string
Session() *model.Session
RequestId() string
IPAddress() string
Path() string
UserAgent() string
AcceptLanguage() string
Context() context.Context
SetSession(s *model.Session)
SetT(i18n.TranslateFunc)
SetRequestId(string)
SetIPAddress(string)
SetUserAgent(string)
SetAcceptLanguage(string)
SetPath(string)
SetContext(ctx context.Context)
GetT() i18n.TranslateFunc
SetLogger(mlog.LoggerIFace)
Logger() mlog.LoggerIFace
SetAppError(*model.AppError)
AppError() *model.AppError
}