Merge pull request #847 from openziti/logging-tweaks

Add additional fields and make field names more consistent
This commit is contained in:
Paul Lorenz
2021-12-14 10:09:23 -05:00
committed by GitHub
7 changed files with 14 additions and 10 deletions
+3 -3
View File
@@ -65,7 +65,7 @@ func (self *baseRequestHandler) returnError(ctx requestContext, err controllerEr
logger := pfxlog.
ContextLogger(self.ch.Label()).
WithError(err).
WithField("router", ctx.GetHandler().getChannel().Id().Token).
WithField("routerId", ctx.GetHandler().getChannel().Id().Token).
WithField("operation", ctx.GetHandler().Label())
if sessionCtx, ok := ctx.(sessionRequestContext); ok {
@@ -81,7 +81,7 @@ func (self *baseRequestHandler) returnError(ctx requestContext, err controllerEr
func (self *baseRequestHandler) logResult(ctx requestContext, err error) {
logger := logrus.
WithField("router", ctx.GetHandler().getChannel().Id().Token).
WithField("routerId", ctx.GetHandler().getChannel().Id().Token).
WithField("operation", ctx.GetHandler().Label())
if sessionCtx, ok := ctx.(sessionRequestContext); ok {
@@ -121,7 +121,7 @@ func (self *baseSessionRequestContext) CleanupOnError() {
if self.newSession && self.session != nil {
logger := logrus.
WithField("operation", self.handler.Label()).
WithField("router", self.sourceRouter.Name)
WithField("routerId", self.sourceRouter.Name)
if err := self.handler.getAppEnv().Handlers.Session.Delete(self.session.Id); err != nil {
logger.WithError(err).Error("unable to delete session created before error encountered")
@@ -68,7 +68,7 @@ func (self *createTerminatorHandler) HandleReceive(msg *channel2.Message, ch cha
}
func (self *createTerminatorHandler) CreateTerminator(ctx *CreateTerminatorRequestContext) {
log := pfxlog.ContextLogger(self.ch.Label()).WithField("token", ctx.req.SessionToken)
log := pfxlog.ContextLogger(self.ch.Label()).WithField("routerId", self.ch.Id().Token).WithField("token", ctx.req.SessionToken)
if !ctx.loadRouter() {
return
@@ -74,7 +74,7 @@ func (self *createTunnelTerminatorHandler) HandleReceive(msg *channel2.Message,
}
func (self *createTunnelTerminatorHandler) CreateTerminator(ctx *CreateTunnelTerminatorRequestContext) {
logger := logrus.WithField("router", self.ch.Id().Token)
logger := logrus.WithField("routerId", self.ch.Id().Token)
if !ctx.loadRouter() {
return
@@ -90,7 +90,7 @@ func (self *createTunnelTerminatorHandler) CreateTerminator(ctx *CreateTunnelTer
return
}
logger = logger.WithField("service", ctx.service.Name)
logger = logger.WithField("serviceId", ctx.service.Id).WithField("service", ctx.service.Name)
if ctx.req.Cost > math.MaxUint16 {
self.returnError(ctx, invalidCost(fmt.Sprintf("invalid cost %v. cost must be between 0 and %v inclusive", ctx.req.Cost, math.MaxUint16)))
@@ -111,6 +111,8 @@ func (self *removeTerminatorHandler) RemoveTerminator(ctx *RemoveTerminatorReque
}
logrus.
WithField("routerId", self.ch.Id().Token).
WithField("serviceId", terminator.Service).
WithField("token", ctx.req.SessionToken).
WithField("terminator", ctx.req.TerminatorId).
Info("removed terminator")
@@ -55,7 +55,7 @@ func (self *removeTunnelTerminatorHandler) HandleReceive(msg *channel2.Message,
}
func (self *removeTunnelTerminatorHandler) RemoveTerminator(ctx *RemoveTunnelTerminatorRequestContext) {
logger := logrus.WithField("router", self.ch.Id().Token).WithField("terminatorId", ctx.terminatorId)
logger := logrus.WithField("routerId", self.ch.Id().Token).WithField("terminatorId", ctx.terminatorId)
if !ctx.loadRouter() {
return
@@ -69,9 +69,9 @@ func (self *updateTerminatorHandler) UpdateTerminator(ctx *UpdateTerminatorReque
}
logger := logrus.
WithField("router", self.ch.Id().Token).
WithField("routerId", self.ch.Id().Token).
WithField("token", ctx.req.SessionToken).
WithField("terminator", ctx.req.TerminatorId).
WithField("terminatorId", ctx.req.TerminatorId).
WithField("cost", ctx.req.Cost).
WithField("updateCost", ctx.req.UpdateCost).
WithField("precedence", ctx.req.Precedence).
@@ -90,6 +90,7 @@ func (self *updateTerminatorHandler) UpdateTerminator(ctx *UpdateTerminatorReque
return
}
logger = logger.WithField("serviceId", terminator.Service)
logger.Info("updated terminator")
responseMsg := channel2.NewMessage(int32(edge_ctrl_pb.ContentType_UpdateTerminatorResponseType), nil)
@@ -67,7 +67,7 @@ func (self *updateTunnelTerminatorHandler) UpdateTerminator(ctx *UpdateTunnelTer
return
}
logger := logrus.WithField("router", self.ch.Id().Token).
logger := logrus.WithField("routerId", self.ch.Id().Token).
WithField("terminatorId", ctx.req.TerminatorId).
WithField("cost", ctx.req.Cost).
WithField("updateCost", ctx.req.UpdateCost).
@@ -83,6 +83,7 @@ func (self *updateTunnelTerminatorHandler) UpdateTerminator(ctx *UpdateTunnelTer
return
}
logger = logger.WithField("serviceId", terminator.Service)
logger.Info("updated terminator")
responseMsg := channel2.NewMessage(int32(edge_ctrl_pb.ContentType_UpdateTunnelTerminatorResponseType), nil)