diff --git a/cmd/minikube/cmd/logs.go b/cmd/minikube/cmd/logs.go index eb13d25147..0b0cc3f7a1 100644 --- a/cmd/minikube/cmd/logs.go +++ b/cmd/minikube/cmd/logs.go @@ -52,6 +52,8 @@ var ( fileOutput string // auditLogs only shows the audit logs auditLogs bool + // lastStartOnly shows logs from last start + lastStartOnly bool ) // logsCmd represents the logs command @@ -111,6 +113,12 @@ var logsCmd = &cobra.Command{ logs.OutputProblems(problems, numberOfProblems, logOutput) return } + if lastStartOnly { + err := logs.OutputLastStart() + if err != nil { + klog.Errorf("failed to output last start logs: %V", err) + } + } err = logs.Output(cr, bs, *co.Config, co.CP.Runner, numberOfLines, logOutput) if err != nil { out.Ln("") @@ -150,4 +158,5 @@ func init() { logsCmd.Flags().StringVar(&nodeName, "node", "", "The node to get logs from. Defaults to the primary control plane.") logsCmd.Flags().StringVar(&fileOutput, "file", "", "If present, writes to the provided file instead of stdout.") logsCmd.Flags().BoolVar(&auditLogs, "audit", false, "Show only the audit logs") + logsCmd.Flags().BoolVar(&lastStartOnly, "last-start-only", false, "Show logs from last start.") } diff --git a/pkg/minikube/logs/logs.go b/pkg/minikube/logs/logs.go index 9a24c80653..361aace369 100644 --- a/pkg/minikube/logs/logs.go +++ b/pkg/minikube/logs/logs.go @@ -221,7 +221,7 @@ func OutputAudit(lines int) error { } // outputLastStart outputs the last start logs. -func outputLastStart() error { +func OutputLastStart() error { out.Styled(style.Empty, "") out.Styled(style.Empty, "==> Last Start <==") fp := localpath.LastStartLog() @@ -256,7 +256,7 @@ func OutputOffline(lines int, logOutput *os.File) { if err := OutputAudit(lines); err != nil { klog.Errorf("failed to output audit logs: %v", err) } - if err := outputLastStart(); err != nil { + if err := OutputLastStart(); err != nil { klog.Errorf("failed to output last start logs: %v", err) }