-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple passthrough logging operator
- Loading branch information
1 parent
45b45b7
commit cdf28a4
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}, | ||
} |