optimize log description

This commit is contained in:
r0n1n7an 2023-08-05 23:21:23 +08:00
parent 9113b09187
commit 121b5b2150
2 changed files with 8 additions and 3 deletions

Binary file not shown.

View File

@ -48,14 +48,16 @@ func init() {
flag.BoolVar(&exclude, "x", false, "Exclude Mode")
flag.BoolVar(&autoBkup, "y", false, "Auto Backup")
flag.IntVar(&diffYear, "d", 6, "Differ Year Of File Time to Backup")
flag.StringVar(&bkupPath, "b", `D:\COMMON_BKUP`, "Path Of Backup")
flag.StringVar(&aodPath, "a", `D:\Vol1\PDLINE\PLANT1\PRELOAD\AOD`, "Path Of AODs")
flag.StringVar(&modPath, "m", `D:\COMMON`, "Path Of Modules")
flag.StringVar(&bkupPath, "b", `D:\COMMON_BKUP`, "Path Of Backup")
flag.StringVar(&aodType, "t", "*", "Type Of AODs, LNB/TNB/SBID/*")
flag.Parse()
}
func main() {
log.SetOutput(os.Stdout)
log.Printf("[MSG] Commandline: %v\r\n", os.Args)
_, err := os.Stat(aodPath)
if err != nil {
log.Printf("[ERR] Path Of AODs Not Exists.\r\n")
@ -190,21 +192,24 @@ func main() {
os.Exit(1)
}
}
ttl := 0
for _, n := range needlessModuleList {
for _, m := range moduleInfoList {
if m.FileName == n {
if m.FileTime.AddDate(diffYear, 0, 0).Before(time.Now()) {
err := os.Rename(m.FilePath, bkupPath+"\\"+m.FileName)
if err != nil {
log.Printf("[ERR] FileName: %s; ErrMsg: %s\r\n", m.FileName, err.Error())
log.Printf("[ERR] FileName: %s;\tErrMsg: %s\r\n", m.FileName, err.Error())
break
}
log.Printf("[MSG] FileName: %s; FileTime: %s\r\n", m.FileName, m.FileTime)
log.Printf("[MSG] FileName: %s;\tFileTime: %s\r\n", m.FileName, m.FileTime)
ttl += 1
break
}
}
}
}
log.Printf("[MSG] Total Backup Modules: %d\r\n", ttl)
}
}