mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 08:38:45 +05:00
unify *log and *dryrun logging across all agents
CGREvent will be included in the logs and dryrun will now take precedence over log.
This commit is contained in:
committed by
Dan Christian Bogos
parent
14d1429446
commit
5b2a8b8784
@@ -63,10 +63,17 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
||||
}
|
||||
}
|
||||
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) {
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) || reqType == utils.MetaDryRun {
|
||||
logPrefix := "LOG"
|
||||
if reqType == utils.MetaDryRun {
|
||||
logPrefix = "DRY_RUN"
|
||||
}
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, processorID: %s, %s message: %s",
|
||||
agentName, reqProcessor.ID, strings.ToLower(agentName[:len(agentName)-5]), agReq.Request.String()))
|
||||
fmt.Sprintf("<%s> %s, processorID: %s, %s message: %s",
|
||||
agentName, logPrefix, reqProcessor.ID, strings.ToLower(agentName[:len(agentName)-5]), agReq.Request.String()))
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> %s, processorID: %s, CGREvent: %s",
|
||||
agentName, logPrefix, reqProcessor.ID, utils.ToIJSON(cgrEv)))
|
||||
}
|
||||
|
||||
replyState := utils.OK
|
||||
@@ -74,10 +81,7 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
||||
default:
|
||||
return false, fmt.Errorf("unknown request type: <%s>", reqType)
|
||||
case utils.MetaNone: // do nothing on CGRateS side
|
||||
case utils.MetaDryRun:
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, processorID: %s, %sMessage: %s",
|
||||
agentName, reqProcessor.ID, agentName[:len(agentName)-5], agReq.Request.String()))
|
||||
case utils.MetaDryRun: // do nothing on CGRateS side, logging handled above
|
||||
case utils.MetaAuthorize:
|
||||
authArgs := sessions.NewV1AuthorizeArgs(
|
||||
reqProcessor.Flags.GetBool(utils.MetaAttributes),
|
||||
@@ -229,15 +233,14 @@ func processRequest(ctx *context.Context, reqProcessor *config.RequestProcessor,
|
||||
return
|
||||
}
|
||||
endTime := time.Now()
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) {
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) || reqType == utils.MetaDryRun {
|
||||
logPrefix := "LOG"
|
||||
if reqType == utils.MetaDryRun {
|
||||
logPrefix = "DRY_RUN"
|
||||
}
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, %s reply: %s",
|
||||
agentName, agentName[:len(agentName)-5], agReq.Reply))
|
||||
}
|
||||
if reqType == utils.MetaDryRun {
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, %s reply: %s",
|
||||
agentName, agentName[:len(agentName)-5], agReq.Reply))
|
||||
fmt.Sprintf("<%s> %s, %s reply: %s",
|
||||
agentName, logPrefix, agentName[:len(agentName)-5], agReq.Reply))
|
||||
}
|
||||
if reqProcessor.Flags.Has(utils.MetaDryRun) {
|
||||
return true, nil
|
||||
|
||||
@@ -335,10 +335,17 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
||||
err = nil // reset the error and continue the processing
|
||||
}
|
||||
}
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) {
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) || reqType == utils.MetaDryRun {
|
||||
logPrefix := "LOG"
|
||||
if reqType == utils.MetaDryRun {
|
||||
logPrefix = "DRY_RUN"
|
||||
}
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, processorID: %s, radius message: %s",
|
||||
utils.RadiusAgent, reqProcessor.ID, agReq.Request.String()))
|
||||
fmt.Sprintf("<%s> %s, processorID: %s, radius message: %s",
|
||||
utils.RadiusAgent, logPrefix, reqProcessor.ID, agReq.Request.String()))
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> %s, processorID: %s, CGREvent: %s",
|
||||
utils.RadiusAgent, logPrefix, reqProcessor.ID, utils.ToIJSON(cgrEv)))
|
||||
}
|
||||
|
||||
replyState := utils.OK
|
||||
@@ -346,10 +353,7 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
||||
default:
|
||||
return false, fmt.Errorf("unknown request type: <%s>", reqType)
|
||||
case utils.MetaNone: // do nothing on CGRateS side
|
||||
case utils.MetaDryRun:
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, processorID: %s, CGREvent: %s",
|
||||
utils.RadiusAgent, reqProcessor.ID, utils.ToJSON(cgrEv)))
|
||||
case utils.MetaDryRun: // do nothing on CGRateS side, logging handled above
|
||||
case utils.MetaAuthorize:
|
||||
authArgs := sessions.NewV1AuthorizeArgs(
|
||||
reqProcessor.Flags.GetBool(utils.MetaAttributes),
|
||||
@@ -509,15 +513,14 @@ func (ra *RadiusAgent) processRequest(req *radigo.Packet, reqProcessor *config.R
|
||||
return false, err
|
||||
}
|
||||
endTime := time.Now()
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) {
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) || reqType == utils.MetaDryRun {
|
||||
logPrefix := "LOG"
|
||||
if reqType == utils.MetaDryRun {
|
||||
logPrefix = "DRY_RUN"
|
||||
}
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, Radius reply: %s",
|
||||
utils.RadiusAgent, agReq.Reply))
|
||||
}
|
||||
if reqType == utils.MetaDryRun {
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, Radius reply: %s",
|
||||
utils.RadiusAgent, agReq.Reply))
|
||||
fmt.Sprintf("<%s> %s, Radius reply: %s",
|
||||
utils.RadiusAgent, logPrefix, agReq.Reply))
|
||||
}
|
||||
if reqProcessor.Flags.Has(utils.MetaDryRun) {
|
||||
return true, nil
|
||||
|
||||
@@ -409,19 +409,23 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor,
|
||||
err = nil // reset the error and continue the processing
|
||||
}
|
||||
}
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) {
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) || reqType == utils.MetaDryRun {
|
||||
logPrefix := "LOG"
|
||||
if reqType == utils.MetaDryRun {
|
||||
logPrefix = "DRY_RUN"
|
||||
}
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, processorID: %s, SIP message: %s",
|
||||
utils.SIPAgent, reqProcessor.ID, agReq.Request.String()))
|
||||
fmt.Sprintf("<%s> %s, processorID: %s, SIP message: %s",
|
||||
utils.SIPAgent, logPrefix, reqProcessor.ID, agReq.Request.String()))
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> %s, processorID: %s, CGREvent: %s",
|
||||
utils.SIPAgent, logPrefix, reqProcessor.ID, utils.ToIJSON(cgrEv)))
|
||||
}
|
||||
switch reqType {
|
||||
default:
|
||||
return false, fmt.Errorf("unknown request type: <%s>", reqType)
|
||||
case utils.MetaNone: // do nothing on CGRateS side
|
||||
case utils.MetaDryRun:
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, processorID: %s, CGREvent: %s",
|
||||
utils.SIPAgent, reqProcessor.ID, utils.ToJSON(cgrEv)))
|
||||
case utils.MetaDryRun: // do nothing on CGRateS side, logging handled above
|
||||
case utils.MetaAuthorize:
|
||||
authArgs := sessions.NewV1AuthorizeArgs(
|
||||
reqProcessor.Flags.GetBool(utils.MetaAttributes),
|
||||
@@ -472,15 +476,14 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor,
|
||||
return false, err
|
||||
}
|
||||
endTime := time.Now()
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) {
|
||||
if reqProcessor.Flags.Has(utils.MetaLog) || reqType == utils.MetaDryRun {
|
||||
logPrefix := "LOG"
|
||||
if reqType == utils.MetaDryRun {
|
||||
logPrefix = "DRY_RUN"
|
||||
}
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, SIP reply: %s",
|
||||
utils.SIPAgent, agReq.Reply))
|
||||
}
|
||||
if reqType == utils.MetaDryRun {
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, SIP reply: %s",
|
||||
utils.SIPAgent, agReq.Reply))
|
||||
fmt.Sprintf("<%s> %s, SIP reply: %s",
|
||||
utils.SIPAgent, logPrefix, agReq.Reply))
|
||||
}
|
||||
if reqProcessor.Flags.Has(utils.MetaDryRun) {
|
||||
return true, nil
|
||||
|
||||
Reference in New Issue
Block a user