diff --git a/plugins/common/log.go b/plugins/common/log.go index 065eceb72..75a1689ab 100644 --- a/plugins/common/log.go +++ b/plugins/common/log.go @@ -3,6 +3,7 @@ package common import ( "fmt" "os" + "strings" ) // LogFail is the failure log formatter @@ -71,6 +72,20 @@ func LogVerboseQuiet(text string) { } } +// LogVerboseQuietContainerLogs is the verbose log formatter for container logs +func LogVerboseQuietContainerLogs(containerID string) { + sc := NewShellCmdWithArgs(DockerBin(), "container", "logs", containerID) + sc.ShowOutput = false + b, err := sc.CombinedOutput() + if err != nil { + LogExclaim(fmt.Sprintf("Failed to fetch container logs: %s", containerID)) + } + + for _, line := range strings.Split(string(b), "\n") { + LogVerboseQuiet(line) + } +} + // LogWarn is the warning log formatter func LogWarn(text string) { fmt.Fprintln(os.Stderr, fmt.Sprintf(" ! %s", text))