Compare commits

...

2 Commits

Author SHA1 Message Date
6b3ebebecb
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
2025-02-01 21:52:26 -05:00
d6da8c8fa7
chore(cmd/joj3): use background context 2025-02-01 21:51:50 -05:00
2 changed files with 14 additions and 2 deletions

View File

@ -147,6 +147,11 @@ func setupSlog(conf *conf.Conf) error {
if logPath != "" {
slog.Info("debug log", "path", logPath)
}
slog.LogAttrs(context.TODO(), slog.LevelInfo, "setup slog attrs", attrs...)
slog.LogAttrs(
context.Background(),
slog.LevelInfo,
"setup slog attrs",
attrs...,
)
return nil
}

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: "",