feat: add command for logging container output
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user