Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change log message field msg -> message #61

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading