feat: mirror log tailing support for logs:vector-logs command

This commit is contained in:
Jose Diaz-Gonzalez
2021-01-07 01:43:55 -05:00
parent b186d9d66c
commit eda71e3ffe
5 changed files with 18 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ Additional commands:`
logs:failed [--all|<app>], Shows the last failed deploy logs
logs:report [<app>] [<flag>], Displays a logs report for one or more apps
logs:set [--global|<app>] <key> <value>, Set or clear a logs property for an app
logs:vector-logs, Tail the logs of the vector container
logs:vector-logs [--num num] [--tail], Display vector log output
logs:vector-start, Start the vector logging container
logs:vector-stop, Stop the vector logging container
`

View File

@@ -47,8 +47,10 @@ func main() {
err = logs.CommandSet(appName, property, value)
case "vector-logs":
args := flag.NewFlagSet("logs:vector-logs", flag.ExitOnError)
num := args.Int("num", 100, "the number of lines to display")
tail := args.Bool("tail", false, "continually stream logs")
args.Parse(os.Args[2:])
err = logs.CommandVectorLogs()
err = logs.CommandVectorLogs(*num, *tail)
case "vector-start":
args := flag.NewFlagSet("logs:vector-start", flag.ExitOnError)
vectorImage := args.String("vector-image", logs.VectorImage, "--vector-image: the name of the docker image to run for vector")

View File

@@ -85,7 +85,7 @@ func CommandSet(appName string, property string, value string) error {
}
// CommandVectorLogs tails the log output for the vector container
func CommandVectorLogs() error {
func CommandVectorLogs(lines int, tail bool) error {
if !common.ContainerExists(vectorContainerName) {
return errors.New("Vector container does not exist")
}
@@ -95,7 +95,7 @@ func CommandVectorLogs() error {
}
common.LogInfo1Quiet("Tailing vector container logs")
common.LogVerboseQuietContainerLogsTail(vectorContainerName)
common.LogVerboseQuietContainerLogsTail(vectorContainerName, lines, tail)
return nil
}