2
2
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:
Alexander Neumann 2015-02-08 14:46:29 +01:00
parent c884704bce
commit 8dc5c2296a

View File

@ -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)
}