mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 12:49:54 +05:00
Update code for actions
This commit is contained in:
committed by
Dan Christian Bogos
parent
b578fd5b04
commit
56fcabe373
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user