diff --git a/cmd/khepri/debug.go b/cmd/khepri/debug.go index bc60b8dad..dc978a51a 100644 --- a/cmd/khepri/debug.go +++ b/cmd/khepri/debug.go @@ -1,4 +1,4 @@ -// +build debug +// +build debug_cmd package main @@ -17,8 +17,8 @@ func initDebugLogger() *log.Logger { // create new log file filename := fmt.Sprintf("khepri-debug-%d-%s", os.Getpid(), time.Now().Format("20060201-150405")) - f, err := os.OpenFile(filepath.Join(os.TempDir(), filename), - os.O_WRONLY|os.O_CREATE, 0600) + path := filepath.Join(os.TempDir(), filename) + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0600) if err != nil { fmt.Fprintf(os.Stderr, "unable to create debug log file: %v", err) os.Exit(2) @@ -26,7 +26,7 @@ func initDebugLogger() *log.Logger { // open logger l := log.New(io.MultiWriter(os.Stderr, f), "DEBUG: ", log.LstdFlags) - fmt.Fprintf(os.Stderr, "logging activated, writing log file %s\n", filename) + fmt.Fprintf(os.Stderr, "debug log for khepri command activated, writing log file %s\n", path) l.Printf("khepri %s", version) return l diff --git a/cmd/khepri/debug_release.go b/cmd/khepri/debug_release.go index 77f5c1b76..ef42f0638 100644 --- a/cmd/khepri/debug_release.go +++ b/cmd/khepri/debug_release.go @@ -1,4 +1,4 @@ -// +build !debug +// +build !debug_cmd package main diff --git a/debug.go b/debug.go index cd4141dc3..80952b3e7 100644 --- a/debug.go +++ b/debug.go @@ -11,15 +11,14 @@ import ( "time" ) -var version = "compiled manually" var debugLogger = initDebugLogger() func initDebugLogger() *log.Logger { // create new log file - filename := fmt.Sprintf("khepri-debug-%d-%s", + filename := fmt.Sprintf("khepri-lib-debug-%d-%s", os.Getpid(), time.Now().Format("20060201-150405")) - f, err := os.OpenFile(filepath.Join(os.TempDir(), filename), - os.O_WRONLY|os.O_CREATE, 0600) + path := filepath.Join(os.TempDir(), filename) + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0600) if err != nil { fmt.Fprintf(os.Stderr, "unable to create debug log file: %v", err) os.Exit(2) @@ -27,8 +26,7 @@ func initDebugLogger() *log.Logger { // open logger l := log.New(io.MultiWriter(os.Stderr, f), "DEBUG: ", log.LstdFlags) - fmt.Fprintf(os.Stderr, "logging activated, writing log file %s\n", filename) - l.Printf("khepri %s", version) + fmt.Fprintf(os.Stderr, "debug log for khepri library activated, writing log file %s\n", path) return l }