Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new flag --last-start-only to only show last start logs #15770

Merged
merged 6 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/minikube/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -75,6 +77,13 @@ var logsCmd = &cobra.Command{
exit.Error(reason.Usage, "Failed to create file", err)
}
}
if lastStartOnly {
err := logs.OutputLastStart()
if err != nil {
klog.Errorf("failed to output last start logs: %v", err)
}
return
}
if auditLogs {
err := logs.OutputAudit(numberOfLines)
if err != nil {
Expand Down Expand Up @@ -150,4 +159,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 only the last start logs.")
}
4 changes: 2 additions & 2 deletions pkg/minikube/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}

Expand Down
13 changes: 7 additions & 6 deletions site/content/en/docs/commands/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ minikube logs [flags]
### Options

```
--audit Show only the audit logs
--file string If present, writes to the provided file instead of stdout.
-f, --follow Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.
-n, --length int Number of lines back to go within the log (default 60)
--node string The node to get logs from. Defaults to the primary control plane.
--problems Show only log entries which point to known problems
--audit Show only the audit logs
--file string If present, writes to the provided file instead of stdout.
-f, --follow Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.
--last-start-only Show only the last start logs.
-n, --length int Number of lines back to go within the log (default 60)
--node string The node to get logs from. Defaults to the primary control plane.
--problems Show only log entries which point to known problems
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@
"Show a list of global command-line options (applies to all commands).": "Zeige eine Liste von globalen Kommandozeilen Parametern (die auf alle Befehle angewendet werden können)",
"Show only log entries which point to known problems": "Zeige nur Log Einträge, die auf bekannte Probleme hinweisen",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "Zeige die aktuellsten Journal Einträge und gebe neue Einträge aus, sobald diese im Journal eingetragen werden.",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "Simuliere den Numa Node Count in Minikube, der unterstützte Numa Node Count Bereich ist 1-8 (nur kvm2 Treiber)",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "Wechsel des kubectl Kontexts für {{.profile_name}} übersprungen, weil --keep-context gesetzt wurde.",
Expand Down
1 change: 1 addition & 0 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",
Expand Down
1 change: 1 addition & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@
"Show a list of global command-line options (applies to all commands).": "Affiche une liste des options de ligne de commande globales (s'applique à toutes les commandes).",
"Show only log entries which point to known problems": "Afficher uniquement les entrées de journal qui pointent vers des problèmes connus",
"Show only the audit logs": "Afficher uniquement les journaux d'audit",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "Affichez uniquement les entrées de journal les plus récentes et imprimez en continu de nouvelles entrées au fur et à mesure qu'elles sont ajoutées au journal.",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "Simulez le nombre de nœuds numa dans minikube, la plage de nombre de nœuds numa pris en charge est de 1 à 8 (pilote kvm2 uniquement)",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "Changement de contexte kubectl ignoré pour {{.profile_name}} car --keep-context a été défini.",
Expand Down
1 change: 1 addition & 0 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@
"Show a list of global command-line options (applies to all commands).": "(全コマンドに適用される) グローバルコマンドラインオプションの一覧を表示します。",
"Show only log entries which point to known problems": "既知の問題を示すログエントリーのみ表示します",
"Show only the audit logs": "監査ログのみ表示します",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "直近のジャーナルエントリーのみ表示し、ジャーナルに追加された新しいエントリーを連続して表示します。",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "minikube 中の NUMA ノードカウントをシミュレートします (対応 NUMA ノードカウント範囲は 1~8 (kvm2 ドライバーのみ))",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "--keep-context が設定されたので、{{.profile_name}} 用 kubectl コンテキストの切替をスキップしました。",
Expand Down
1 change: 1 addition & 0 deletions translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",
Expand Down
1 change: 1 addition & 0 deletions translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "Pokaż logi które wskazują na znane problemy",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "Zignorowano zmianę kontekstu kubectl dla {{.profile_name}} ponieważ --keep-context zostało przekazane",
Expand Down
1 change: 1 addition & 0 deletions translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",
Expand Down
1 change: 1 addition & 0 deletions translations/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",
Expand Down
1 change: 1 addition & 0 deletions translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@
"Show a list of global command-line options (applies to all commands).": "显示全局命令行选项列表 (应用于所有命令)。",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the last start logs.": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",
Expand Down