mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 00:10:45 +02:00
logging: remove ctx from global log methods (#5337)
* log: remove warn * log: update debug * log: update info * remove level, log * remove contextLogger function
This commit is contained in:
parent
1ccaf1b22b
commit
d2c14cd6d2
53 changed files with 150 additions and 198 deletions
|
@ -49,7 +49,7 @@ func (srv *Server) UpdateConfig(options ...ServerOption) {
|
|||
|
||||
cfg := newServerConfig(options...)
|
||||
if cmp.Equal(cfg, srv.cfg, cmp.AllowUnexported(serverConfig{})) {
|
||||
log.Debug(ctx).Msg("databroker: no changes detected, re-using existing DBs")
|
||||
log.Ctx(ctx).Debug().Msg("databroker: no changes detected, re-using existing DBs")
|
||||
return
|
||||
}
|
||||
srv.cfg = cfg
|
||||
|
@ -75,7 +75,7 @@ func (srv *Server) UpdateConfig(options ...ServerOption) {
|
|||
func (srv *Server) AcquireLease(ctx context.Context, req *databroker.AcquireLeaseRequest) (*databroker.AcquireLeaseResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "databroker.grpc.AcquireLease")
|
||||
defer span.End()
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("name", req.GetName()).
|
||||
Dur("duration", req.GetDuration().AsDuration()).
|
||||
Msg("acquire lease")
|
||||
|
@ -102,7 +102,7 @@ func (srv *Server) AcquireLease(ctx context.Context, req *databroker.AcquireLeas
|
|||
func (srv *Server) Get(ctx context.Context, req *databroker.GetRequest) (*databroker.GetResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "databroker.grpc.Get")
|
||||
defer span.End()
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("type", req.GetType()).
|
||||
Str("id", req.GetId()).
|
||||
Msg("get")
|
||||
|
@ -129,7 +129,7 @@ func (srv *Server) Get(ctx context.Context, req *databroker.GetRequest) (*databr
|
|||
func (srv *Server) ListTypes(ctx context.Context, _ *emptypb.Empty) (*databroker.ListTypesResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "databroker.grpc.ListTypes")
|
||||
defer span.End()
|
||||
log.Debug(ctx).Msg("list types")
|
||||
log.Ctx(ctx).Debug().Msg("list types")
|
||||
|
||||
db, err := srv.getBackend()
|
||||
if err != nil {
|
||||
|
@ -146,7 +146,7 @@ func (srv *Server) ListTypes(ctx context.Context, _ *emptypb.Empty) (*databroker
|
|||
func (srv *Server) Query(ctx context.Context, req *databroker.QueryRequest) (*databroker.QueryResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "databroker.grpc.Query")
|
||||
defer span.End()
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("type", req.GetType()).
|
||||
Str("query", req.GetQuery()).
|
||||
Int64("offset", req.GetOffset()).
|
||||
|
@ -202,7 +202,7 @@ func (srv *Server) Put(ctx context.Context, req *databroker.PutRequest) (*databr
|
|||
|
||||
records := req.GetRecords()
|
||||
if len(records) == 1 {
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("record-type", records[0].GetType()).
|
||||
Str("record-id", records[0].GetId()).
|
||||
Msg("put")
|
||||
|
@ -211,7 +211,7 @@ func (srv *Server) Put(ctx context.Context, req *databroker.PutRequest) (*databr
|
|||
for _, record := range records {
|
||||
recordType = record.GetType()
|
||||
}
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Int("record-count", len(records)).
|
||||
Str("record-type", recordType).
|
||||
Msg("put")
|
||||
|
@ -241,7 +241,7 @@ func (srv *Server) Patch(ctx context.Context, req *databroker.PatchRequest) (*da
|
|||
|
||||
records := req.GetRecords()
|
||||
if len(records) == 1 {
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("record-type", records[0].GetType()).
|
||||
Str("record-id", records[0].GetId()).
|
||||
Msg("patch")
|
||||
|
@ -250,7 +250,7 @@ func (srv *Server) Patch(ctx context.Context, req *databroker.PatchRequest) (*da
|
|||
for _, record := range records {
|
||||
recordType = record.GetType()
|
||||
}
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Int("record-count", len(records)).
|
||||
Str("record-type", recordType).
|
||||
Msg("patch")
|
||||
|
@ -277,7 +277,7 @@ func (srv *Server) Patch(ctx context.Context, req *databroker.PatchRequest) (*da
|
|||
func (srv *Server) ReleaseLease(ctx context.Context, req *databroker.ReleaseLeaseRequest) (*emptypb.Empty, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "databroker.grpc.ReleaseLease")
|
||||
defer span.End()
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("name", req.GetName()).
|
||||
Str("id", req.GetId()).
|
||||
Msg("release lease")
|
||||
|
@ -299,7 +299,7 @@ func (srv *Server) ReleaseLease(ctx context.Context, req *databroker.ReleaseLeas
|
|||
func (srv *Server) RenewLease(ctx context.Context, req *databroker.RenewLeaseRequest) (*emptypb.Empty, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "databroker.grpc.RenewLease")
|
||||
defer span.End()
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("name", req.GetName()).
|
||||
Str("id", req.GetId()).
|
||||
Dur("duration", req.GetDuration().AsDuration()).
|
||||
|
@ -351,7 +351,7 @@ func (srv *Server) Sync(req *databroker.SyncRequest, stream databroker.DataBroke
|
|||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Uint64("server_version", req.GetServerVersion()).
|
||||
Uint64("record_version", req.GetRecordVersion()).
|
||||
Msg("sync")
|
||||
|
@ -388,7 +388,7 @@ func (srv *Server) SyncLatest(req *databroker.SyncLatestRequest, stream databrok
|
|||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
log.Debug(ctx).
|
||||
log.Ctx(ctx).Debug().
|
||||
Str("type", req.GetType()).
|
||||
Msg("sync latest")
|
||||
|
||||
|
@ -457,10 +457,10 @@ func (srv *Server) newBackendLocked() (backend storage.Backend, err error) {
|
|||
|
||||
switch srv.cfg.storageType {
|
||||
case config.StorageInMemoryName:
|
||||
log.Info(ctx).Msg("using in-memory store")
|
||||
log.Ctx(ctx).Info().Msg("using in-memory store")
|
||||
return inmemory.New(), nil
|
||||
case config.StoragePostgresName:
|
||||
log.Info(ctx).Msg("using postgres store")
|
||||
log.Ctx(ctx).Info().Msg("using postgres store")
|
||||
backend = postgres.New(srv.cfg.storageConnectionString)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported storage type: %s", srv.cfg.storageType)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue