Compare commits
No commits in common. "4e3313b6db54ff6c6a43df41a1afdf082628320b" and "5bb4e3ff45c0914d933f5210b0aa01541ded3d65" have entirely different histories.
4e3313b6db
...
5bb4e3ff45
66
cmd/pew.go
66
cmd/pew.go
@ -12,7 +12,6 @@ import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -91,8 +90,6 @@ type PewCmd struct {
|
||||
OutputOnSuccess bool `help:"show output on success"`
|
||||
RealtimeOutput bool `help:"show realtime output"`
|
||||
|
||||
LogDir string `help:"write logs to directory"`
|
||||
|
||||
Endless bool `help:"endless tests"`
|
||||
EndlessTimeout time.Duration `help:"timeout between tests" default:"1m"`
|
||||
EndlessStress string `help:"endless stress script" type:"existingfile"`
|
||||
@ -406,54 +403,39 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
|
||||
|
||||
defer swg.Done()
|
||||
|
||||
var logDirWriter *zerolog.ConsoleWriter
|
||||
if cmd.LogDir != "" {
|
||||
logdir := filepath.Join(cmd.LogDir, cmd.Tag)
|
||||
err := os.MkdirAll(logdir, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("mkdir %s", logdir)
|
||||
return
|
||||
}
|
||||
logdir := "logs/" + cmd.Tag
|
||||
err := os.MkdirAll(logdir, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("mkdir %s", logdir)
|
||||
return
|
||||
}
|
||||
|
||||
logfile := fmt.Sprintf("logs/%s/%s-%s-%s.log",
|
||||
cmd.Tag,
|
||||
ki.Distro.ID.String(),
|
||||
ki.Distro.Release,
|
||||
ki.KernelRelease,
|
||||
)
|
||||
f, err := os.Create(logfile)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("create %s", logfile)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
logfile := fmt.Sprintf("logs/%s/%s-%s-%s.log",
|
||||
cmd.Tag,
|
||||
ki.Distro.ID.String(),
|
||||
ki.Distro.Release,
|
||||
ki.KernelRelease,
|
||||
)
|
||||
f, err := os.Create(logfile)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("create %s", logfile)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
logDirWriter = &zerolog.ConsoleWriter{
|
||||
slog := zerolog.New(zerolog.MultiLevelWriter(
|
||||
&ConsoleWriter,
|
||||
&FileWriter,
|
||||
&zerolog.ConsoleWriter{
|
||||
Out: f,
|
||||
FieldsExclude: []string{
|
||||
"distro_release",
|
||||
"distro_type",
|
||||
"kernel",
|
||||
"command",
|
||||
"workdir",
|
||||
},
|
||||
NoColor: true,
|
||||
}
|
||||
}
|
||||
|
||||
var slog zerolog.Logger
|
||||
if logDirWriter != nil {
|
||||
slog = zerolog.New(zerolog.MultiLevelWriter(
|
||||
&ConsoleWriter,
|
||||
&FileWriter,
|
||||
logDirWriter,
|
||||
))
|
||||
} else {
|
||||
slog = zerolog.New(zerolog.MultiLevelWriter(
|
||||
&ConsoleWriter,
|
||||
&FileWriter,
|
||||
))
|
||||
}
|
||||
},
|
||||
))
|
||||
|
||||
switch LogLevel {
|
||||
case zerolog.TraceLevel, zerolog.DebugLevel:
|
||||
|
@ -466,7 +466,7 @@ func (c Container) build(imagePath string) (output string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Container) Run(workdir string, cmds []string) (out string, err error) {
|
||||
func (c Container) Run(workdir string, cmds []string) (out string, err error) {
|
||||
flog := c.Log.With().
|
||||
Str("workdir", workdir).
|
||||
Str("command", fmt.Sprintf("%v", cmds)).
|
||||
@ -535,7 +535,7 @@ func (c *Container) Run(workdir string, cmds []string) (out string, err error) {
|
||||
}
|
||||
c.handleCommandsOutput(m)
|
||||
out += m + "\n"
|
||||
flog.Trace().Str("container stdout", m).Msg("")
|
||||
flog.Trace().Str("stdout", m).Msg("")
|
||||
}
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user