mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +00:00
Use different tags for debug log
This commit is contained in:
parent
cf33b01582
commit
616a2c749d
3 changed files with 9 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// +build !debug
|
||||
// +build !debug_cmd
|
||||
|
||||
package main
|
||||
|
||||
|
|
10
debug.go
10
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue