forked from TrueCloudLab/frostfs-node
Aleksey Savchuk
f0c43c8d80
Use `zap.Error` instead of `zap.String` for logging errors: change all expressions like `zap.String("error", err.Error())` or `zap.String("err", err.Error())` to `zap.Error(err)`. Leave similar expressions with other messages unchanged, for example, `zap.String("last_error", lastErr.Error())` or `zap.String("reason", ctx.Err().Error())`. This change was made by applying the following patch: ```diff @@ var err expression @@ -zap.String("error", err.Error()) +zap.Error(err) @@ var err expression @@ -zap.String("err", err.Error()) +zap.Error(err) ``` Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
27 lines
861 B
Go
27 lines
861 B
Go
package util
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// LogServiceError writes error message of object service to provided logger.
|
|
func LogServiceError(ctx context.Context, l *logger.Logger, req string, node network.AddressGroup, err error) {
|
|
l.Error(ctx, logs.UtilObjectServiceError,
|
|
zap.String("node", network.StringifyGroup(node)),
|
|
zap.String("request", req),
|
|
zap.Error(err),
|
|
)
|
|
}
|
|
|
|
// LogWorkerPoolError writes debug error message of object worker pool to provided logger.
|
|
func LogWorkerPoolError(ctx context.Context, l *logger.Logger, req string, err error) {
|
|
l.Error(ctx, logs.UtilCouldNotPushTaskToWorkerPool,
|
|
zap.String("request", req),
|
|
zap.Error(err),
|
|
)
|
|
}
|