From 56fcabe373bc98f88dc4be145026248976ff5736 Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 19 Jan 2021 18:02:24 +0200 Subject: [PATCH] Update code for actions --- actions/actdata.go | 11 +++++++++++ actions/libactions.go | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/actions/actdata.go b/actions/actdata.go index aec366165..b663143f5 100644 --- a/actions/actdata.go +++ b/actions/actdata.go @@ -19,6 +19,7 @@ along with this program. If not, see package actions import ( + "fmt" "net" "github.com/cgrates/cgrates/utils" @@ -51,6 +52,16 @@ func (aD *ActData) FieldAsString(fldPath []string) (val string, err error) { // FieldAsInterface implements utils.DataProvider func (aD *ActData) FieldAsInterface(fldPath []string) (val interface{}, err error) { + if len(fldPath) < 1 { + return nil, fmt.Errorf("invalid fieldPath: <%+v>", fldPath) + } + switch fldPath[0] { + case utils.MetaReq: + case utils.MetaOpts: + default: + return nil, fmt.Errorf("invalid prefix for fieldPath: <%+v>", fldPath) + } + return } diff --git a/actions/libactions.go b/actions/libactions.go index 6cbdd34f3..eeaa70b35 100644 --- a/actions/libactions.go +++ b/actions/libactions.go @@ -20,6 +20,7 @@ package actions import ( "context" + "encoding/json" "fmt" "github.com/cgrates/cgrates/config" @@ -103,7 +104,6 @@ func newActioner(cfg *config.CGRConfig, fltrS *engine.FilterS, dm *engine.DataMa return nil, fmt.Errorf("unsupported action type: <%s>", aCfg.Type) } - return } // actioner is implemented by each action type @@ -128,5 +128,7 @@ func (aL *actLog) cfg() *engine.APAction { // execute implements actioner interface func (aL *actLog) execute(ctx context.Context, data *ActData) (err error) { + body, _ := json.Marshal(data) + utils.Logger.Info(fmt.Sprintf("LOG Event: %s", body)) return }