Save start logs to lastStart.txt in minikube dir

pull/10465/head
Steven Powell 2021-02-12 17:00:34 -07:00
parent 26351ff6c6
commit 91e8c0980b
1 changed files with 13 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"regexp"
"strconv"
@ -29,6 +30,7 @@ import (
"k8s.io/klog/v2"
// Register drivers
"k8s.io/minikube/pkg/minikube/localpath"
_ "k8s.io/minikube/pkg/minikube/registry/drvs"
// Force exp dependency
@ -142,6 +144,17 @@ func setFlags() {
klog.Warningf("Unable to set default flag value for alsologtostderr: %v", err)
}
}
if os.Args[1] == "start" {
fp := filepath.Join(localpath.MiniPath(), "logs", "lastStart.txt")
if err := os.Remove(fp); err != nil {
klog.Warningf("Unable to delete file %s: %v", err)
}
if !pflag.CommandLine.Changed("log_file") {
if err := pflag.Set("log_file", fp); err != nil {
klog.Warningf("Unable to set default flag value for log_file: %v", err)
}
}
}
// make sure log_dir exists if log_file is not also set - the log_dir is mutually exclusive with the log_file option
// ref: https://github.com/kubernetes/klog/blob/52c62e3b70a9a46101f33ebaf0b100ec55099975/klog.go#L491