mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Merge pull request #182 from harrywhite4/logFilter
Return stdout only from docker-compose command
This commit is contained in:
commit
5348d2f821
1 changed files with 6 additions and 5 deletions
|
|
@ -60,7 +60,7 @@ func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd) {
|
||||||
func (c *OSCommand) RunCommandWithOutput(command string) (string, error) {
|
func (c *OSCommand) RunCommandWithOutput(command string) (string, error) {
|
||||||
cmd := c.ExecutableFromString(command)
|
cmd := c.ExecutableFromString(command)
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
output, err := sanitisedCommandOutput(cmd.CombinedOutput())
|
output, err := sanitisedCommandOutput(cmd.Output())
|
||||||
c.Log.Warn(fmt.Sprintf("'%s': %s", command, time.Since(before)))
|
c.Log.Warn(fmt.Sprintf("'%s': %s", command, time.Since(before)))
|
||||||
return output, err
|
return output, err
|
||||||
}
|
}
|
||||||
|
|
@ -115,11 +115,12 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
|
||||||
outputString := string(output)
|
outputString := string(output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// errors like 'exit status 1' are not very useful so we'll create an error
|
// errors like 'exit status 1' are not very useful so we'll create an error
|
||||||
// from the combined output
|
// from stderr if we got an ExitError
|
||||||
if outputString == "" {
|
exitError, ok := err.(*exec.ExitError)
|
||||||
return "", WrapError(err)
|
if ok {
|
||||||
|
return outputString, errors.New(string(exitError.Stderr))
|
||||||
}
|
}
|
||||||
return outputString, errors.New(outputString)
|
return "", WrapError(err)
|
||||||
}
|
}
|
||||||
return outputString, nil
|
return outputString, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue