feat(parser/log): support specify log level
All checks were successful
submodules sync / sync (push) Successful in 31s
build / build (push) Successful in 1m5s
build / trigger-build-image (push) Successful in 6s

This commit is contained in:
张泊明518370910136 2025-02-01 21:52:26 -05:00
parent d6da8c8fa7
commit 6b3ebebecb
GPG Key ID: D47306D7062CDA9D

View File

@ -1,6 +1,7 @@
package log
import (
"context"
"encoding/json"
"fmt"
"log/slog"
@ -11,6 +12,7 @@ import (
type Conf struct {
FileName string `default:"stdout"`
Msg string `default:"log msg"`
Level int `default:"0"`
}
type Log struct{}
@ -30,7 +32,12 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
for key, value := range data {
args = append(args, key, value)
}
slog.Info(conf.Msg, args...)
slog.Default().Log(
context.Background(),
slog.Level(conf.Level),
conf.Msg,
args...,
)
return stage.ParserResult{
Score: 0,
Comment: "",