로그 삭제 수정 - dir 삭제로 변경

main
JungJun 2 years ago
parent 059f4503e4
commit 4651170aa9

@ -14,7 +14,6 @@ import (
"gitlab.com/ics_cinnamon/voiceStatistics/icsconf"
"gitlab.com/ics_cinnamon/voiceStatistics/icserror"
"gitlab.com/ics_cinnamon/voiceStatistics/icsutil"
)
type IcsLog struct {
@ -247,7 +246,6 @@ func (s *IcsLog) DelLog() {
return
}
//var derr *icserror.IcsError = nil
delLogCount := 0
defer func() {
if err := recover(); err != nil {
@ -272,32 +270,29 @@ func (s *IcsLog) DelLog() {
// s.Printf(LOG_LEVEL_ERROR, -1, " Read Log Dir error - %s \n", rderr)
// fmt.Printf("Read Log Dir error - %s", rderr)
} else {
var logYYYY, logMM, logDD string
var YYYY, MM, DD string
for _, file := range files {
/*
TODO
1.
2. -
3. 0
*/
logTime := strings.SplitN(file.Name(), ".", -1)[1]
logYYYY, logMM, logDD = logTime[:4], logTime[4:6], logTime[6:8]
chgLogTime, perr := time.Parse("2006-01-02", fmt.Sprintf("%s%s%s", logYYYY, logMM, logDD))
_, cerr := strconv.Atoi(file.Name())
if cerr != nil {
// s.Printf(LOG_LEVEL_ERROR, -1, "Voice Date Parse Error- %s \n", file.Name())
continue
}
YYYY, MM, DD = file.Name()[:4], file.Name()[4:6], file.Name()[6:8]
chgVTime, perr := time.Parse("2006-01-02", fmt.Sprintf("%s%s%s", YYYY, MM, DD))
if perr != nil {
// s.Printf(LOG_LEVEL_ERROR, -1, " Log Time Parse error - %s \n", perr)
// fmt.Printf("Log Time Parse error - %s", perr)
// s.Printf(LOG_LEVEL_ERROR, -1, " Voice Time Parse error - %s \n", perr)
// fmt.Printf("Voice Time Parse error - %s\n", perr)
} else {
diff := delTime.Sub(chgLogTime)
// diff > 0 => delete log
diff := delTime.Sub(chgVTime)
if diff > 0 {
delResult := icsutil.DeleteFile(s.Path, file.Name())
if delResult != "" {
delResult := os.RemoveAll(fmt.Sprintf("%s/%s", s.Path, file.Name()))
if delResult != nil {
// s.Printf(LOG_LEVEL_ERROR, -1, " Delete File error - %s \n", delResult)
// fmt.Printf("Delete File error [%s] - %s \n", file.Name(), delResult.Error())
} else {
// s.Printf(LOG_LEVEL_INFO, -1, " Delete %s!!!!\n", file.Name())
// fmt.Printf("Delete %s!!!!\n", file.Name())
delLogCount += 1
// s.Printf(LOG_LEVEL_INFO, -1, " Delete %s \n", file.Name())
// fmt.Printf("Delete %s \n", file.Name())
}
}
}

Loading…
Cancel
Save