|
|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"math"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"sync"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
@ -203,8 +204,19 @@ func (s IcsService) LogWatcher() *icserror.IcsError {
|
|
|
|
|
// /logs/voiceGW/tlo/{YYYYMMDD}/LGT.001.202207140313.log
|
|
|
|
|
// s.log.Path: /logs/voiceGW/tlo 로 변경
|
|
|
|
|
// 일자별 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)
|
|
|
|
|
|
|
|
|
|
_, err := os.Stat(s.log.LogFileName)
|
|
|
|
|
if err == nil {
|
|
|
|
|
var oerr error
|
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(s.log.LogFileName), 0777)
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
|
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)
|
|
|
|
@ -213,6 +225,37 @@ func (s IcsService) LogWatcher() *icserror.IcsError {
|
|
|
|
|
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()
|
|
|
|
|
// l.Printf(icslog.LOG_LEVEL_INFO, -1, "Log Watcher: Updated Log File - %s", s.log.LogFileName)
|
|
|
|
|