From 084b1b3def014ca1c4b66de7b5d5d3353446bb1b Mon Sep 17 00:00:00 2001 From: ko_oler <kooler89@gmail.com> Date: Tue, 2 Apr 2024 14:24:21 +0300 Subject: [PATCH] CallerFromContext -> Caller --- pkg/clients/middleware/logging_middleware.go | 14 +++++++------- .../middleware/logging_middleware.go | 17 +++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pkg/clients/middleware/logging_middleware.go b/pkg/clients/middleware/logging_middleware.go index c8ce011a..8a9abafa 100644 --- a/pkg/clients/middleware/logging_middleware.go +++ b/pkg/clients/middleware/logging_middleware.go @@ -25,7 +25,7 @@ func LoggingMiddleware(logger *zap.Logger) Middleware { func (m *loggingMiddleware) Create(ctx context.Context, client *clients.Client) (created *clients.Client, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(clients.EventCreate), logzap.Object(client), ) @@ -43,7 +43,7 @@ func (m *loggingMiddleware) Create(ctx context.Context, client *clients.Client) func (m *loggingMiddleware) Get(ctx context.Context, spaceId, clientId string) (client *clients.Client, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Object(id.NewClientId(spaceId, clientId)), ) @@ -58,7 +58,7 @@ func (m *loggingMiddleware) Get(ctx context.Context, spaceId, clientId string) ( func (m *loggingMiddleware) GetBy(ctx context.Context, spaceId string, params *clients.GetByParams) (client *clients.Client, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), ) client, err = m.next.GetBy(ctx, spaceId, params) @@ -72,7 +72,7 @@ func (m *loggingMiddleware) GetBy(ctx context.Context, spaceId string, params *c func (m *loggingMiddleware) List(ctx context.Context, spaceId string) (clients []*clients.Client, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), ) clients, err = m.next.List(ctx, spaceId) @@ -86,7 +86,7 @@ func (m *loggingMiddleware) List(ctx context.Context, spaceId string) (clients [ func (m *loggingMiddleware) Update(ctx context.Context, client *clients.Client) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(clients.EventUpdate), logzap.Object(client), ) @@ -104,7 +104,7 @@ func (m *loggingMiddleware) Update(ctx context.Context, client *clients.Client) func (m *loggingMiddleware) Delete(ctx context.Context, spaceId, clientId string) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(clients.EventDelete), logzap.Object(id.NewClientId(spaceId, clientId)), ) @@ -130,7 +130,7 @@ func (m *loggingMiddleware) Enable(ctx context.Context, spaceId, clientId string } logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(event), logzap.Object(id.NewClientId(spaceId, clientId)), ) diff --git a/pkg/environments/middleware/logging_middleware.go b/pkg/environments/middleware/logging_middleware.go index df753096..63ad2429 100644 --- a/pkg/environments/middleware/logging_middleware.go +++ b/pkg/environments/middleware/logging_middleware.go @@ -2,6 +2,7 @@ package middleware import ( "context" + "git.perx.ru/perxis/perxis-go/id" "git.perx.ru/perxis/perxis-go/pkg/environments" @@ -25,7 +26,7 @@ func LoggingMiddleware(logger *zap.Logger) Middleware { func (m *loggingMiddleware) Create(ctx context.Context, env *environments.Environment) (created *environments.Environment, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(environments.EventCreate), logzap.Object(env), ) @@ -43,7 +44,7 @@ func (m *loggingMiddleware) Create(ctx context.Context, env *environments.Enviro func (m *loggingMiddleware) Delete(ctx context.Context, spaceId string, envId string) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(environments.EventDelete), logzap.Object(id.NewEnvironmentId(spaceId, envId)), ) @@ -61,7 +62,7 @@ func (m *loggingMiddleware) Delete(ctx context.Context, spaceId string, envId st func (m *loggingMiddleware) Get(ctx context.Context, spaceId string, envId string) (env *environments.Environment, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Object(id.NewEnvironmentId(spaceId, envId)), ) @@ -76,7 +77,7 @@ func (m *loggingMiddleware) Get(ctx context.Context, spaceId string, envId strin func (m *loggingMiddleware) List(ctx context.Context, spaceId string) (envs []*environments.Environment, err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), ) envs, err = m.next.List(ctx, spaceId) @@ -90,7 +91,7 @@ func (m *loggingMiddleware) List(ctx context.Context, spaceId string) (envs []*e func (m *loggingMiddleware) Migrate(ctx context.Context, spaceId string, envId string, options ...*environments.MigrateOptions) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(environments.EventMigrate), logzap.Object(id.NewEnvironmentId(spaceId, envId)), ) @@ -113,7 +114,7 @@ func (m *loggingMiddleware) Migrate(ctx context.Context, spaceId string, envId s func (m *loggingMiddleware) RemoveAlias(ctx context.Context, spaceId string, envId string, alias string) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(environments.EventUpdate), logzap.Object(id.NewEnvironmentId(spaceId, envId)), ) @@ -131,7 +132,7 @@ func (m *loggingMiddleware) RemoveAlias(ctx context.Context, spaceId string, env func (m *loggingMiddleware) SetAlias(ctx context.Context, spaceId string, envId string, alias string) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(environments.EventUpdate), logzap.Object(id.NewEnvironmentId(spaceId, envId)), ) @@ -149,7 +150,7 @@ func (m *loggingMiddleware) SetAlias(ctx context.Context, spaceId string, envId func (m *loggingMiddleware) Update(ctx context.Context, env *environments.Environment) (err error) { logger := m.logger.With( - logzap.CallerFromContext(ctx, ""), + logzap.Caller(ctx), logzap.Event(environments.EventUpdate), logzap.Object(env), ) -- GitLab