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