Fix NEXTLOG on restart

This commit is contained in:
Neale Pickett 2015-02-11 15:58:55 -07:00
parent 6bfdc2fad2
commit d1beac1965
1 changed files with 5 additions and 3 deletions

View File

@ -42,10 +42,12 @@ func (lf *Logfile) rotate() error {
return err return err
} }
currentPath = path.Join(lf.baseDir, "log", "current")
if lf.file == nil { if lf.file == nil {
// Set lf.file just so we can write out NEXTLOG. // Set lf.file just so we can write out NEXTLOG.
// If this fails, that's okay // If this fails, that's okay
lf.file, _ = os.OpenFile("current", os.O_WRONLY|os.O_APPEND, 0666) lf.file, _ = os.OpenFile(currentPath, os.O_WRONLY|os.O_APPEND, 0666)
} }
if lf.file != nil { if lf.file != nil {
@ -61,8 +63,8 @@ func (lf *Logfile) rotate() error {
lf.file = newf lf.file = newf
// Record symlink to new log // Record symlink to new log
os.Remove(path.Join(lf.baseDir, "log", "current")) os.Remove(currentPath)
os.Symlink(fn, path.Join(lf.baseDir, "log", "current")) os.Symlink(fn, currentPath)
logmsg := fmt.Sprintf(". PREVLOG %s", lf.name) logmsg := fmt.Sprintf(". PREVLOG %s", lf.name)
lf.writeln(logmsg) lf.writeln(logmsg)