Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Keep up to 10 old sysup log files for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoore134 committed Jun 14, 2019
1 parent 3b6aca6 commit 711456e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ import (
"log"
"os"
"os/exec"
"strconv"
)

func RotateLog() {
nums := []int{9, 8, 7, 6, 5, 4, 3, 2, 1}
for _, num := range nums {
if _, err := os.Stat(defines.LogFile + "." + strconv.Itoa(num)); os.IsNotExist(err) {
continue
}

cmd := exec.Command("mv", defines.LogFile+"."+strconv.Itoa(num), defines.LogFile+"."+strconv.Itoa(num+1))
cmd.Run()
}

if _, err := os.Stat(defines.LogFile); os.IsNotExist(err) {
return
}
cmd := exec.Command("mv", defines.LogFile, defines.LogFile+".previous")

cmd := exec.Command("mv", defines.LogFile, defines.LogFile+".1")
cmd.Run()

}

func LogToFile(info string) {
Expand Down

0 comments on commit 711456e

Please sign in to comment.