mirror of
https://github.com/octoleo/restic.git
synced 2024-12-26 20:30:19 +00:00
debug: do not seek after creating log file
This commit is contained in:
parent
c884704bce
commit
8dc5c2296a
@ -34,6 +34,15 @@ func initDebugLogger() (lgr *log.Logger) {
|
||||
// open logfile
|
||||
f, err := os.OpenFile(debugfile, os.O_WRONLY|os.O_APPEND, 0600)
|
||||
|
||||
if err == nil {
|
||||
// seek to the end
|
||||
_, err = f.Seek(2, 0)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unable to seek to the end of %v: %v\n", debugfile, err)
|
||||
os.Exit(3)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil && os.IsNotExist(err) {
|
||||
// create logfile
|
||||
f, err = os.OpenFile(debugfile, os.O_WRONLY|os.O_CREATE, 0600)
|
||||
@ -44,13 +53,6 @@ func initDebugLogger() (lgr *log.Logger) {
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
// seek to the end
|
||||
_, err = f.Seek(2, 0)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unable to seek to the end of %v: %v\n", debugfile, err)
|
||||
os.Exit(3)
|
||||
}
|
||||
|
||||
// open logger
|
||||
lgr = log.New(f, "", log.LstdFlags)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user