feat(parser/log): support specify log level
This commit is contained in:
parent
d6da8c8fa7
commit
6b3ebebecb
|
@ -1,6 +1,7 @@
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
@ -11,6 +12,7 @@ import (
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
FileName string `default:"stdout"`
|
FileName string `default:"stdout"`
|
||||||
Msg string `default:"log msg"`
|
Msg string `default:"log msg"`
|
||||||
|
Level int `default:"0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Log struct{}
|
type Log struct{}
|
||||||
|
@ -30,7 +32,12 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||||
for key, value := range data {
|
for key, value := range data {
|
||||||
args = append(args, key, value)
|
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{
|
return stage.ParserResult{
|
||||||
Score: 0,
|
Score: 0,
|
||||||
Comment: "",
|
Comment: "",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user