From b079835cb321d60ae162a1d2c188d07188f4c31c Mon Sep 17 00:00:00 2001 From: Pavel Merzlyakov Date: Thu, 8 Jun 2023 09:54:36 +0300 Subject: [PATCH] logger for RpcContext --- tpl/codegen_bundle.twig | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tpl/codegen_bundle.twig b/tpl/codegen_bundle.twig index ab0c9e4..119a89e 100644 --- a/tpl/codegen_bundle.twig +++ b/tpl/codegen_bundle.twig @@ -16,6 +16,7 @@ import ( "git.bit5.ru/gomodules/metadb" "github.com/doug-martin/goqu/v9" "github.com/doug-martin/goqu/v9/exp" + "github.com/go-logr/logr" "github.com/pkg/errors" ) @@ -104,6 +105,8 @@ type CreateRpcFunc func(uint32) (Rpc, error) type RpcContext struct { ctx context.Context + logger logr.Logger + ip net.IP version versioning.Version platform uint8 @@ -129,23 +132,23 @@ func NewRpcContext( } } -func (rctx RpcContext) Context() context.Context { +func (rctx *RpcContext) Context() context.Context { return rctx.ctx } -func (rctx RpcContext) IP() net.IP { +func (rctx *RpcContext) IP() net.IP { return rctx.ip } -func (rctx RpcContext) Version() versioning.Version { +func (rctx *RpcContext) Version() versioning.Version { return rctx.version } -func (rctx RpcContext) Platform() uint8 { +func (rctx *RpcContext) Platform() uint8 { return rctx.platform } -func (rctx RpcContext) ExtraValue(key string) (string, bool) { +func (rctx *RpcContext) ExtraValue(key string) (string, bool) { if rctx.extras == nil { return "", false } @@ -159,10 +162,18 @@ func (rctx *RpcContext) SetPlayer(playerId uint32, extId string) { rctx.extId = extId } -func (rctx RpcContext) PlayerId() uint32 { +func (rctx *RpcContext) PlayerId() uint32 { return rctx.playerId } -func (rctx RpcContext) ExtId() string { +func (rctx *RpcContext) ExtId() string { return rctx.extId } + +func (rctx *RpcContext) SetLogger(logger logr.Logger) { + rctx.logger = logger +} + +func (rctx *RpcContext) Logger() logr.Logger { + return rctx.logger +}