통합통계 로그 삭제

main
JungJun 2 years ago
parent 62cda2c212
commit 68ba2f89cb

@ -7,7 +7,6 @@ import (
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -251,9 +250,9 @@ func (s *IcsLog) DelLog() {
switch v := err.(type) { switch v := err.(type) {
case error: case error:
icserror.ICSERRFileOpen.SetError(v) icserror.ICSERRFileOpen.SetError(v)
s.Printf(LOG_LEVEL_WARN, -1, "PANIC! %s\n%s", icserror.ICSERRFileOpen.GetError().Error(), string(debug.Stack())) // s.Printf(LOG_LEVEL_WARN, -1, "PANIC! %s\n%s", icserror.ICSERRFileOpen.GetError().Error(), string(debug.Stack()))
default: default:
s.Print(LOG_LEVEL_WARN, -1, icserror.ICSERRFileOpen.GetError().Error()) // s.Print(LOG_LEVEL_WARN, -1, icserror.ICSERRFileOpen.GetError().Error())
} }
} }
//derr = icserror.ICSERRFileOpen //derr = icserror.ICSERRFileOpen
@ -266,8 +265,8 @@ func (s *IcsLog) DelLog() {
files, rderr := ioutil.ReadDir(s.Path) files, rderr := ioutil.ReadDir(s.Path)
if rderr != nil { if rderr != nil {
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 logYYYY, logMM, logDD string
for _, file := range files { for _, file := range files {
@ -281,8 +280,8 @@ func (s *IcsLog) DelLog() {
logYYYY, logMM, logDD = logTime[:4], logTime[4:6], logTime[6:8] 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)) 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, " Log Time Parse error - %s \n", perr)
fmt.Printf("Log Time Parse error - %s", perr) // fmt.Printf("Log Time Parse error - %s", perr)
} else { } else {
diff := delTime.Sub(chgLogTime) diff := delTime.Sub(chgLogTime)
@ -290,16 +289,16 @@ func (s *IcsLog) DelLog() {
if diff > 0 { if diff > 0 {
delResult := icsutil.DeleteFile(s.Path, file.Name()) delResult := icsutil.DeleteFile(s.Path, file.Name())
if delResult != "" { if delResult != "" {
s.Printf(LOG_LEVEL_ERROR, -1, " Delete File error - %s \n", delResult) // s.Printf(LOG_LEVEL_ERROR, -1, " Delete File error - %s \n", delResult)
} 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 delLogCount += 1
} }
} }
} }
} }
} }
s.Printf(LOG_LEVEL_INFO, -1, " Delete File Count - %d \n", delLogCount) // s.Printf(LOG_LEVEL_INFO, -1, " Delete File Count - %d \n", delLogCount)
fmt.Printf("Log Delete Count : %d", delLogCount) // fmt.Printf("Log Delete Count : %d", delLogCount)
} }

@ -102,9 +102,9 @@ func main() {
//fmt.Printf("Service Started - %d\n================================\n", pid) //fmt.Printf("Service Started - %d\n================================\n", pid)
info = "\n" + info info = "\n" + info
icsLog.Print(icslog.LOG_LEVEL_INFO, -1, info) // icsLog.Print(icslog.LOG_LEVEL_INFO, -1, info)
icsLog.Print(icslog.LOG_LEVEL_INFO, -1, "Service Started") // icsLog.Print(icslog.LOG_LEVEL_INFO, -1, "Service Started")
icsLog.Print(icslog.LOG_LEVEL_INFO, -1, "================================") // icsLog.Print(icslog.LOG_LEVEL_INFO, -1, "================================")
///////////////////////////////// /////////////////////////////////
//icsutil.CloseSTDIO() //icsutil.CloseSTDIO()

Loading…
Cancel
Save