Update code for actions

This commit is contained in:
TeoV
2021-01-19 18:02:24 +02:00
committed by Dan Christian Bogos
parent b578fd5b04
commit 56fcabe373
2 changed files with 14 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
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
}

View File

@@ -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
}