|
|
@ -14,7 +14,6 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
"gitlab.com/ics_cinnamon/voiceStatistics/icsconf"
|
|
|
|
"gitlab.com/ics_cinnamon/voiceStatistics/icsconf"
|
|
|
|
"gitlab.com/ics_cinnamon/voiceStatistics/icserror"
|
|
|
|
"gitlab.com/ics_cinnamon/voiceStatistics/icserror"
|
|
|
|
"gitlab.com/ics_cinnamon/voiceStatistics/icsutil"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type IcsLog struct {
|
|
|
|
type IcsLog struct {
|
|
|
@ -247,7 +246,6 @@ func (s *IcsLog) DelLog() {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//var derr *icserror.IcsError = nil
|
|
|
|
//var derr *icserror.IcsError = nil
|
|
|
|
delLogCount := 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
if err := recover(); err != nil {
|
|
|
|
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)
|
|
|
|
// s.Printf(LOG_LEVEL_ERROR, -1, " Read Log Dir error - %s \n", rderr)
|
|
|
|
// fmt.Printf("Read Log Dir error - %s", rderr)
|
|
|
|
// fmt.Printf("Read Log Dir error - %s", rderr)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var logYYYY, logMM, logDD string
|
|
|
|
var YYYY, MM, DD string
|
|
|
|
for _, file := range files {
|
|
|
|
for _, file := range files {
|
|
|
|
/*
|
|
|
|
_, cerr := strconv.Atoi(file.Name())
|
|
|
|
TODO
|
|
|
|
if cerr != nil {
|
|
|
|
1. 로그 파일을 시간으로 변환
|
|
|
|
// s.Printf(LOG_LEVEL_ERROR, -1, "Voice Date Parse Error- %s \n", file.Name())
|
|
|
|
2. 현재 시간 - 삭제기간
|
|
|
|
continue
|
|
|
|
3. 둘 시간 차이가 0 이상 나면 삭제대상
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
logTime := strings.SplitN(file.Name(), ".", -1)[1]
|
|
|
|
YYYY, MM, DD = file.Name()[:4], file.Name()[4:6], file.Name()[6:8]
|
|
|
|
logYYYY, logMM, logDD = logTime[:4], logTime[4:6], logTime[6:8]
|
|
|
|
chgVTime, perr := time.Parse("2006-01-02", fmt.Sprintf("%s%s%s", YYYY, MM, DD))
|
|
|
|
chgLogTime, perr := time.Parse("2006-01-02", fmt.Sprintf("%s%s%s", logYYYY, logMM, logDD))
|
|
|
|
|
|
|
|
if perr != nil {
|
|
|
|
if perr != nil {
|
|
|
|
// s.Printf(LOG_LEVEL_ERROR, -1, " Log Time Parse error - %s \n", perr)
|
|
|
|
// s.Printf(LOG_LEVEL_ERROR, -1, " Voice Time Parse error - %s \n", perr)
|
|
|
|
// fmt.Printf("Log Time Parse error - %s", perr)
|
|
|
|
// fmt.Printf("Voice Time Parse error - %s\n", perr)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
diff := delTime.Sub(chgLogTime)
|
|
|
|
diff := delTime.Sub(chgVTime)
|
|
|
|
|
|
|
|
|
|
|
|
// diff > 0 => delete log
|
|
|
|
|
|
|
|
if diff > 0 {
|
|
|
|
if diff > 0 {
|
|
|
|
delResult := icsutil.DeleteFile(s.Path, file.Name())
|
|
|
|
delResult := os.RemoveAll(fmt.Sprintf("%s/%s", s.Path, file.Name()))
|
|
|
|
if delResult != "" {
|
|
|
|
if delResult != nil {
|
|
|
|
// s.Printf(LOG_LEVEL_ERROR, -1, " Delete File error - %s \n", delResult)
|
|
|
|
// 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 {
|
|
|
|
} else {
|
|
|
|
// s.Printf(LOG_LEVEL_INFO, -1, " Delete %s!!!!\n", file.Name())
|
|
|
|
// s.Printf(LOG_LEVEL_INFO, -1, " Delete %s \n", file.Name())
|
|
|
|
// fmt.Printf("Delete %s!!!!\n", file.Name())
|
|
|
|
// fmt.Printf("Delete %s \n", file.Name())
|
|
|
|
delLogCount += 1
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|