Add *log flag for logging ees events

This commit is contained in:
gezimbll
2023-11-03 05:27:17 -04:00
committed by Dan Christian Bogos
parent c4fefedefa
commit 9e2a629b82
2 changed files with 24 additions and 1 deletions

View File

@@ -600,7 +600,7 @@ const CGRATES_CFG_JSON = `
}, // extra options for exporter
"timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
"filters": [], // limit parsing based on the filters
"flags": [], // flags to influence the event processing
"flags": [], // flags to influence the event processing <*attributes|*log>
"attribute_ids": [], // select Attribute profiles instead of discovering them
"attribute_context": "", // context used to discover matching Attribute profiles
"synchronous": false, // block processing until export has a result

View File

@@ -320,6 +320,29 @@ func ExportWithAttempts(exp EventExporter, eEv any, key string) (err error) {
utils.EEs, exp.Cfg().ID, err.Error()))
return
}
if exp.Cfg().Flags.GetBool(utils.MetaLog) {
var evLog string
switch c := eEv.(type) {
case []byte:
evLog = string(c)
case string:
evLog = c
case *HTTPPosterRequest:
evByt, cancast := c.Body.([]byte)
if cancast {
evLog = string(evByt)
break
}
evLog = utils.ToJSON(c.Body)
default:
evLog = utils.ToJSON(c)
}
utils.Logger.Info(
fmt.Sprintf("<%s> LOG, exporter <%s>, message: %s",
utils.EEs, exp.Cfg().ID, evLog))
}
for i := 0; i < exp.Cfg().Attempts; i++ {
if err = exp.ExportEvent(eEv, key); err == nil ||
err == utils.ErrDisconnected { // special error in case the exporter was closed