feat: more logs
This commit is contained in:
parent
d723d98de0
commit
f5ba04b8e7
|
@ -133,5 +133,6 @@ func parseMsg(confRoot, confName, msg string) (conf Conf, group string, err erro
|
|||
strings.ToLower(conventionalCommit.Description), "joj") {
|
||||
group = "joj"
|
||||
}
|
||||
slog.Debug("conf loaded", "conf", conf)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -70,5 +70,8 @@ func setupSlog(logPath string) error {
|
|||
// Set the default logger
|
||||
logger := slog.New(multiHandler)
|
||||
slog.SetDefault(logger)
|
||||
if logPath != "" {
|
||||
slog.Info("debug log", "path", logPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -71,10 +71,13 @@ func generateStages(conf Conf, group string) ([]stage.Stage, error) {
|
|||
ParserConf: s.Parser.With,
|
||||
})
|
||||
}
|
||||
slog.Debug("stages generated", "stages", stages)
|
||||
return stages, nil
|
||||
}
|
||||
|
||||
func outputResult(outputPath string, results []stage.StageResult) error {
|
||||
slog.Info("output result start", "path", outputPath)
|
||||
slog.Debug("output result start", "path", outputPath, "results", results)
|
||||
content, err := json.Marshal(results)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -124,22 +127,18 @@ func mainImpl() error {
|
|||
if err := setupSlog(conf.LogPath); err != nil { // after conf is loaded
|
||||
return err
|
||||
}
|
||||
slog.Info("debug log", "path", conf.LogPath)
|
||||
slog.Debug("conf loaded", "conf", conf)
|
||||
executors.InitWithConf(conf.SandboxExecServer, conf.SandboxToken)
|
||||
stages, err := generateStages(conf, group)
|
||||
if err != nil {
|
||||
slog.Error("generate stages", "error", err)
|
||||
return err
|
||||
}
|
||||
slog.Debug("stages generated", "stages", stages)
|
||||
defer stage.Cleanup()
|
||||
results, err := stage.Run(stages)
|
||||
if err != nil {
|
||||
slog.Error("run stages", "error", err)
|
||||
return err
|
||||
}
|
||||
slog.Debug("stages run done", "results", results)
|
||||
if err := outputResult(conf.OutputPath, results); err != nil {
|
||||
slog.Error("output result", "error", err)
|
||||
return err
|
||||
|
|
|
@ -9,10 +9,12 @@ func Run(stages []Stage) (stageResults []StageResult, err error) {
|
|||
var executorResults []ExecutorResult
|
||||
var parserResults []ParserResult
|
||||
var forceQuit bool
|
||||
slog.Info("stage run start")
|
||||
for _, stage := range stages {
|
||||
slog.Info("stage start", "name", stage.Name)
|
||||
slog.Info("executor run start")
|
||||
slog.Debug("executor run start", "cmds", stage.ExecutorCmds)
|
||||
slog.Info("executor run start", "name", stage.ExecutorName)
|
||||
slog.Debug("executor run start", "name", stage.ExecutorName,
|
||||
"cmds", stage.ExecutorCmds)
|
||||
executor, ok := executorMap[stage.ExecutorName]
|
||||
if !ok {
|
||||
slog.Error("executor not found", "name", stage.ExecutorName)
|
||||
|
@ -28,8 +30,9 @@ func Run(stages []Stage) (stageResults []StageResult, err error) {
|
|||
for _, executorResult := range executorResults {
|
||||
slog.Debug("executor run done", "result.Files", executorResult.Files)
|
||||
}
|
||||
slog.Info("parser run start")
|
||||
slog.Debug("parser run start", "conf", stage.ParserConf)
|
||||
slog.Info("parser run start", "name", stage.ParserName)
|
||||
slog.Debug("parser run start", "name", stage.ParserName,
|
||||
"conf", stage.ParserConf)
|
||||
parser, ok := parserMap[stage.ParserName]
|
||||
if !ok {
|
||||
slog.Error("parser not found", "name", stage.ParserName)
|
||||
|
@ -56,12 +59,11 @@ func Run(stages []Stage) (stageResults []StageResult, err error) {
|
|||
}
|
||||
|
||||
func Cleanup() {
|
||||
slog.Info("stage cleanup start")
|
||||
for name, executor := range executorMap {
|
||||
slog.Debug("executor cleanup start", "name", name)
|
||||
err := executor.Cleanup()
|
||||
if err != nil {
|
||||
slog.Error("executor cleanup error", "name", name, "error", err)
|
||||
}
|
||||
slog.Debug("executor cleanup done", "name", name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user