From adb788f8e5486140e299ba77f55db1e8b87e25f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Wed, 18 Dec 2024 15:32:42 +0100 Subject: [PATCH] debug: Log metadata --- internal/pkg/service/stream/encryption/log.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/pkg/service/stream/encryption/log.go b/internal/pkg/service/stream/encryption/log.go index 36f5f06680..28376eddae 100644 --- a/internal/pkg/service/stream/encryption/log.go +++ b/internal/pkg/service/stream/encryption/log.go @@ -23,6 +23,13 @@ func NewLoggedEncryptor(ctx context.Context, encryptor cloudencrypt.Encryptor, l } func (encryptor *LoggedEncryptor) Encrypt(ctx context.Context, plaintext []byte, metadata cloudencrypt.Metadata) ([]byte, error) { + meta := "" + for k, v := range metadata { + meta += k + ": " + v + ", " + } + + encryptor.logger.Infof(ctx, "encryption metadata: " + meta) + if len(plaintext) == 0 { err := errors.New("text should not be empty") encryptor.logger.Infof(ctx, "encryption error: %s", err.Error()) @@ -41,6 +48,13 @@ func (encryptor *LoggedEncryptor) Encrypt(ctx context.Context, plaintext []byte, } func (encryptor *LoggedEncryptor) Decrypt(ctx context.Context, ciphertext []byte, metadata cloudencrypt.Metadata) ([]byte, error) { + meta := "" + for k, v := range metadata { + meta += k + ": " + v + ", " + } + + encryptor.logger.Infof(ctx, "decryption metadata: " + meta) + if len(ciphertext) == 0 { err := errors.New("text should not be empty") encryptor.logger.Infof(ctx, "decryption error: %s", err.Error())