From 49bd76632b71e1c99c7cac54c4509d6df57a0bc9 Mon Sep 17 00:00:00 2001 From: Tim Scheuermann Date: Thu, 23 Jun 2022 18:07:02 +0300 Subject: [PATCH] MM-45039 create mctx package (#20505) Thanks to @agnivade and @isacikgoz for their input --- app/request/context.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/request/context.go b/app/request/context.go index df98cc28c4..c3d895fdc5 100644 --- a/app/request/context.go +++ b/app/request/context.go @@ -8,6 +8,7 @@ import ( "github.com/mattermost/mattermost-server/v6/model" "github.com/mattermost/mattermost-server/v6/shared/i18n" + "github.com/mattermost/mattermost-server/v6/shared/mlog" ) type Context struct { @@ -18,6 +19,8 @@ type Context struct { path string userAgent string acceptLanguage string + logger mlog.LoggerIFace + err *model.AppError context context.Context } @@ -97,3 +100,19 @@ func (c *Context) SetContext(ctx context.Context) { func (c *Context) GetT() i18n.TranslateFunc { return c.t } + +func (c *Context) SetLogger(logger mlog.LoggerIFace) { + c.logger = logger +} + +func (c *Context) Logger() mlog.LoggerIFace { + return c.logger +} + +func (c *Context) SetAppError(err *model.AppError) { + c.err = err +} + +func (c *Context) AppError() *model.AppError { + return c.err +}