Skip to content

Commit

Permalink
Change log message field msg -> message (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
bma13 authored Sep 12, 2024
1 parent ce3b3da commit 3ed2ee8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
5 changes: 3 additions & 2 deletions cmd/integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package main

import (
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"log"
"time"
"ydbcp/internal/types"
pb "ydbcp/pkg/proto/ydbcp/v1alpha1"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand Down
7 changes: 1 addition & 6 deletions internal/handlers/delete_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ func DBOperationHandler(
config config.Config,
queryBuilder queries.WriteTableQuery,
) error {
xlog.Info(
ctx, "DBOperationHandler",
zap.String("OperationType", operation.GetType().String()),
zap.String("OperationState", operation.GetState().String()),
zap.String("message", operation.GetMessage()),
)
xlog.Info(ctx, "DBOperationHandler", zap.String("OperationMessage", operation.GetMessage()))

if operation.GetType() != types.OperationTypeDB {
return fmt.Errorf(
Expand Down
8 changes: 1 addition & 7 deletions internal/handlers/restore_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ func RBOperationHandler(
client client.ClientConnector,
config config.Config,
) error {
xlog.Info(
ctx, "received operation",
zap.String("id", operation.GetID()),
zap.String("type", string(operation.GetType())),
zap.String("state", string(operation.GetState())),
zap.String("message", operation.GetMessage()),
)
xlog.Info(ctx, "RBOperationHandler", zap.String("OperationMessage", operation.GetMessage()))

if operation.GetType() != types.OperationTypeRB {
return fmt.Errorf(
Expand Down
4 changes: 4 additions & 0 deletions internal/handlers/take_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import (
"ydbcp/internal/connectors/db/yql/queries"
"ydbcp/internal/connectors/s3"
"ydbcp/internal/types"
"ydbcp/internal/util/xlog"
pb "ydbcp/pkg/proto/ydbcp/v1alpha1"

table_types "github.com/ydb-platform/ydb-go-sdk/v3/table/types"
"go.uber.org/zap"

"google.golang.org/protobuf/types/known/timestamppb"

Expand All @@ -36,6 +38,8 @@ func TBOperationHandler(
config config.Config,
getQueryBuilder func(ctx context.Context) queries.WriteTableQuery,
) error {
xlog.Info(ctx, "TBOperationHandler", zap.String("OperationMessage", operation.GetMessage()))

if operation.GetType() != types.OperationTypeTB {
return fmt.Errorf("wrong operation type %s != %s", operation.GetType(), types.OperationTypeTB)
}
Expand Down
4 changes: 3 additions & 1 deletion internal/util/xlog/ctxlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ func from(ctx context.Context) *zap.Logger {
return l
}
// Fallback, so we don't need to manually init logger in every test.
SetInternalLogger(zap.Must(zap.NewDevelopmentConfig().Build()))
cfg := zap.NewDevelopmentConfig()
cfg.EncoderConfig.MessageKey = "message"
SetInternalLogger(zap.Must(cfg.Build()))
return from(ctx)
}

Expand Down
1 change: 1 addition & 0 deletions internal/util/xlog/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func SetupLogging(verbose bool) *zap.Logger {
}
cfg := zap.NewProductionConfig()
cfg.Level.SetLevel(level)
cfg.EncoderConfig.MessageKey = "message"

l, err := cfg.Build()
if err != nil {
Expand Down

0 comments on commit 3ed2ee8

Please sign in to comment.