|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
"math"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
@ -203,17 +204,59 @@ func (s IcsService) LogWatcher() *icserror.IcsError {
|
|
|
|
// /logs/voiceGW/tlo/{YYYYMMDD}/LGT.001.202207140313.log
|
|
|
|
// /logs/voiceGW/tlo/{YYYYMMDD}/LGT.001.202207140313.log
|
|
|
|
// s.log.Path: /logs/voiceGW/tlo 로 변경
|
|
|
|
// s.log.Path: /logs/voiceGW/tlo 로 변경
|
|
|
|
// 일자별 rotate를 날짜 폴더로 이동
|
|
|
|
// 일자별 rotate를 날짜 폴더로 이동
|
|
|
|
|
|
|
|
|
|
|
|
s.log.LogFileName = fmt.Sprintf("%s/%d%02d%02d/LGT.%03d.%d%02d%02d%02d%02d.log", s.log.Path, y2, m2, d2, s.config.InfoConfig.ServerID, y2, m2, d2, h2, mi2)
|
|
|
|
s.log.LogFileName = fmt.Sprintf("%s/%d%02d%02d/LGT.%03d.%d%02d%02d%02d%02d.log", s.log.Path, y2, m2, d2, s.config.InfoConfig.ServerID, y2, m2, d2, h2, mi2)
|
|
|
|
var oerr error
|
|
|
|
|
|
|
|
s.log.LogFile, oerr = os.OpenFile(s.log.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
_, err := os.Stat(s.log.LogFileName)
|
|
|
|
if oerr != nil {
|
|
|
|
if err == nil {
|
|
|
|
icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
var oerr error
|
|
|
|
//icserror.ICSERRFileOpen.PrintWithCaller(1)
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(s.log.LogFileName), 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
s.log.M.Unlock()
|
|
|
|
icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
return icserror.ICSERRFileOpen
|
|
|
|
icserror.ICSERRMakeDir.PrintWithCaller(0)
|
|
|
|
|
|
|
|
return icserror.ICSERRMakeDir
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.log.LogFile, oerr = os.OpenFile(s.log.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
|
|
|
icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
//icserror.ICSERRFileOpen.PrintWithCaller(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.log.M.Unlock()
|
|
|
|
|
|
|
|
return icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var oerr error
|
|
|
|
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(s.log.LogFileName), 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
|
|
|
fmt.Println("mkdir err : ", oerr)
|
|
|
|
|
|
|
|
icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
|
|
|
|
icserror.ICSERRMakeDir.PrintWithCaller(0)
|
|
|
|
|
|
|
|
return icserror.ICSERRMakeDir
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("mkdir success")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.log.LogFile, oerr = os.OpenFile(s.log.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
|
|
|
icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
//icserror.ICSERRFileOpen.PrintWithCaller(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.log.M.Unlock()
|
|
|
|
|
|
|
|
return icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// s.log.LogFileName = fmt.Sprintf("%s/%d%02d%02d/LGT.%03d.%d%02d%02d%02d%02d.log", s.log.Path, y2, m2, d2, s.config.InfoConfig.ServerID, y2, m2, d2, h2, mi2)
|
|
|
|
|
|
|
|
// var oerr error
|
|
|
|
|
|
|
|
// s.log.LogFile, oerr = os.OpenFile(s.log.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
// if oerr != nil {
|
|
|
|
|
|
|
|
// icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
// //icserror.ICSERRFileOpen.PrintWithCaller(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// s.log.M.Unlock()
|
|
|
|
|
|
|
|
// return icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
s.log.M.Unlock()
|
|
|
|
s.log.M.Unlock()
|
|
|
|
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Log Watcher: Updated Log File - %s", s.log.LogFileName)
|
|
|
|
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Log Watcher: Updated Log File - %s", s.log.LogFileName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|