feat: add command for logging container output

This commit is contained in:
Jose Diaz-Gonzalez
2020-08-30 13:25:06 -04:00
parent 939cb67daa
commit 77f211c372

View File

@@ -3,6 +3,7 @@ package common
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
) )
// LogFail is the failure log formatter // 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 // LogWarn is the warning log formatter
func LogWarn(text string) { func LogWarn(text string) {
fmt.Fprintln(os.Stderr, fmt.Sprintf(" ! %s", text)) fmt.Fprintln(os.Stderr, fmt.Sprintf(" ! %s", text))