Skip to content

Commit

Permalink
Add simple passthrough logging operator
Browse files Browse the repository at this point in the history
  • Loading branch information
kairichard committed Oct 18, 2019
1 parent 45b45b7 commit cdf28a4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/elem/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func init() {
Register(imageEncodeCfg)

Register(shellExecuteCfg)
Register(systemLogCfg)

variableStores = make(map[string]*variableStore)
variableMutex = &sync.Mutex{}
Expand Down
43 changes: 43 additions & 0 deletions pkg/elem/system_log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package elem

import (
"github.com/Bitspark/slang/pkg/log"

"github.com/Bitspark/slang/pkg/core"
"github.com/google/uuid"
)

var systemLogId = uuid.MustParse("8f9c02df-da41-4266-b486-0c22173a6383")
var systemLogCfg = &builtinConfig{
blueprint: core.Blueprint{
Id: systemLogId,
Meta: core.BlueprintMetaDef{
Name: "log",
ShortDescription: "Logs any value passed through the configured logger",
Icon: "align-center",
Tags: []string{"system"},
DocURL: "https://bitspark.de/slang/docs/operator/log",
},
ServiceDefs: map[string]*core.ServiceDef{
core.MAIN_SERVICE: {
In: core.TypeDef{
Type: "generic",
Generic: "valueType",
},
Out: core.TypeDef{
Type: "generic",
Generic: "valueType",
},
},
},
},
opFunc: func(op *core.Operator) {
in := op.Main().In()
out := op.Main().Out()
for !op.CheckStop() {
i := in.Pull()
log.Print(i)
out.Push(i)
}
},
}

0 comments on commit cdf28a4

Please sign in to comment.