add a LogInfo expr helper (#2179)
This commit is contained in:
parent
6bb20fa951
commit
4ff8f498ce
2 changed files with 17 additions and 1 deletions
|
@ -377,6 +377,13 @@ var exprFuncs = []exprCustomFunc{
|
|||
new(func(string, string) bool),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "LogInfo",
|
||||
function: LogInfo,
|
||||
signature: []interface{}{
|
||||
new(func(string, ...interface{}) bool),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
//go 1.20 "CutPrefix": strings.CutPrefix,
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package exprhelpers
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
//Wrappers for stdlib strings function exposed in expr
|
||||
|
||||
|
@ -67,3 +71,8 @@ func TrimSpace(params ...any) (any, error) {
|
|||
func TrimSuffix(params ...any) (any, error) {
|
||||
return strings.TrimSuffix(params[0].(string), params[1].(string)), nil
|
||||
}
|
||||
|
||||
func LogInfo(params ...any) (any, error) {
|
||||
log.Infof(params[0].(string), params[1:]...)
|
||||
return true, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue