core/logging: change log.Error function (#5251)

* core/logging: change log.Error function

* use request id
This commit is contained in:
Caleb Doxsey 2024-09-05 15:42:46 -06:00 committed by GitHub
parent 97bf5edc54
commit dad954ae16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 163 additions and 166 deletions

View file

@ -1,7 +1,6 @@
package databroker
import (
"context"
"crypto/tls"
"time"
@ -76,7 +75,7 @@ func WithGetSharedKey(getSharedKey func() ([]byte, error)) ServerOption {
return func(cfg *serverConfig) {
sharedKey, err := getSharedKey()
if err != nil {
log.Error(context.TODO()).Err(err).Msgf("shared key is required and must be %d bytes long", cryptutil.DefaultKeySize)
log.Error().Err(err).Msgf("shared key is required and must be %d bytes long", cryptutil.DefaultKeySize)
return
}
cfg.secret = sharedKey

View file

@ -102,7 +102,7 @@ func (src *ConfigSource) rebuild(ctx context.Context, firstTime firstTime) {
err := src.buildNewConfigLocked(ctx, cfg)
if err != nil {
health.ReportError(health.BuildDatabrokerConfig, err)
log.Error(ctx).Err(err).Msg("databroker: failed to build new config")
log.Ctx(ctx).Error().Err(err).Msg("databroker: failed to build new config")
return
}
health.ReportOK(health.BuildDatabrokerConfig)
@ -147,7 +147,7 @@ func (src *ConfigSource) buildNewConfigLocked(ctx context.Context, cfg *config.C
policies, errs = errgrouputil.Build(ctx, policyBuilders...)
if len(errs) > 0 {
for _, err := range errs {
log.Error(ctx).Msg(err.Error())
log.Ctx(ctx).Error().Msg(err.Error())
}
return fmt.Errorf("error building policies")
}
@ -262,7 +262,7 @@ func (src *ConfigSource) runUpdater(cfg *config.Config) {
cc, err := src.outboundGRPCConnection.Get(ctx, connectionOptions)
if err != nil {
log.Error(ctx).Err(err).Msg("databroker: failed to create gRPC connection to data broker")
log.Ctx(ctx).Error().Err(err).Msg("databroker: failed to create gRPC connection to data broker")
return
}
@ -312,7 +312,7 @@ func (s *syncerHandler) UpdateRecords(ctx context.Context, _ uint64, records []*
var cfgpb configpb.Config
err := record.GetData().UnmarshalTo(&cfgpb)
if err != nil {
log.Error(ctx).Err(err).Msg("databroker: error decoding config")
log.Ctx(ctx).Error().Err(err).Msg("databroker: error decoding config")
delete(s.src.dbConfigs, record.GetId())
continue
}

View file

@ -57,7 +57,7 @@ func (srv *Server) UpdateConfig(options ...ServerOption) {
if srv.backend != nil {
err := srv.backend.Close()
if err != nil {
log.Error(ctx).Err(err).Msg("databroker: error closing backend")
log.Ctx(ctx).Error().Err(err).Msg("databroker: error closing backend")
}
srv.backend = nil
}
@ -65,7 +65,7 @@ func (srv *Server) UpdateConfig(options ...ServerOption) {
if srv.registry != nil {
err := srv.registry.Close()
if err != nil {
log.Error(ctx).Err(err).Msg("databroker: error closing registry")
log.Ctx(ctx).Error().Err(err).Msg("databroker: error closing registry")
}
srv.registry = nil
}