|
|
@ -145,50 +145,61 @@ func NewIcsLog(conf *icsconf.LogConfig, level int, output int, path string, disk
|
|
|
|
|
|
|
|
|
|
|
|
stat, err := os.Stat(gIcsLog.LogFileName)
|
|
|
|
stat, err := os.Stat(gIcsLog.LogFileName)
|
|
|
|
if err == nil {
|
|
|
|
if err == nil {
|
|
|
|
if gIcsLog.checkLogRotate() && stat.Size()/ONEMB >= int64(gIcsLog.logSize) {
|
|
|
|
fmt.Println("err == nil", stat)
|
|
|
|
rotateNum := gIcsLog.getTodayLogFileNum()
|
|
|
|
var oerr error
|
|
|
|
//fmt.Println("rotate num:", rotateNum)
|
|
|
|
gIcsLog.LogFile, oerr = os.OpenFile(gIcsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
if rotateNum > 0 && rotateNum < gIcsLog.rotateNum {
|
|
|
|
if oerr != nil {
|
|
|
|
gIcsLog.shiftLogFiles(rotateNum)
|
|
|
|
//fmt.Println(gIcsLog.LogFileName)
|
|
|
|
|
|
|
|
icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
var oerr error
|
|
|
|
reterr = icserror.ICSERRFileOpen
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(gIcsLog.LogFileName), 0777)
|
|
|
|
reterr.PrintWithCaller(0)
|
|
|
|
if oerr != nil {
|
|
|
|
return
|
|
|
|
fmt.Println("mkdir err : ", oerr)
|
|
|
|
|
|
|
|
icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
|
|
|
|
icserror.ICSERRMakeDir.PrintWithCaller(0)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("mkdir success")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gIcsLog.LogFile, oerr = os.OpenFile(gIcsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
|
|
|
//fmt.Println(gIcsLog.LogFileName)
|
|
|
|
|
|
|
|
icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
reterr = icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
reterr.PrintWithCaller(0)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if stat.Size()/ONEMB < int64(gIcsLog.logSize) {
|
|
|
|
|
|
|
|
var oerr error
|
|
|
|
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(gIcsLog.LogFileName), 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
|
|
|
icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
|
|
|
|
icserror.ICSERRMakeDir.PrintWithCaller(0)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gIcsLog.LogFile, oerr = os.OpenFile(gIcsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
if oerr != nil {
|
|
|
|
|
|
|
|
//fmt.Println(gIcsLog.LogFileName)
|
|
|
|
|
|
|
|
icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
reterr = icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
reterr.PrintWithCaller(0)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if gIcsLog.checkLogRotate() && stat.Size()/ONEMB >= int64(gIcsLog.logSize) {
|
|
|
|
|
|
|
|
// rotateNum := gIcsLog.getTodayLogFileNum()
|
|
|
|
|
|
|
|
// //fmt.Println("rotate num:", rotateNum)
|
|
|
|
|
|
|
|
// if rotateNum > 0 && rotateNum < gIcsLog.rotateNum {
|
|
|
|
|
|
|
|
// gIcsLog.shiftLogFiles(rotateNum)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var oerr error
|
|
|
|
|
|
|
|
// oerr = os.MkdirAll(filepath.Dir(gIcsLog.LogFileName), 0777)
|
|
|
|
|
|
|
|
// if oerr != nil {
|
|
|
|
|
|
|
|
// fmt.Println("mkdir err : ", oerr)
|
|
|
|
|
|
|
|
// icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
|
|
|
|
// icserror.ICSERRMakeDir.PrintWithCaller(0)
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fmt.Println("mkdir success")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// gIcsLog.LogFile, oerr = os.OpenFile(gIcsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
// if oerr != nil {
|
|
|
|
|
|
|
|
// //fmt.Println(gIcsLog.LogFileName)
|
|
|
|
|
|
|
|
// icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
// reterr = icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
// reterr.PrintWithCaller(0)
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else if stat.Size()/ONEMB < int64(gIcsLog.logSize) {
|
|
|
|
|
|
|
|
// var oerr error
|
|
|
|
|
|
|
|
// oerr = os.MkdirAll(filepath.Dir(gIcsLog.LogFileName), 0777)
|
|
|
|
|
|
|
|
// if oerr != nil {
|
|
|
|
|
|
|
|
// icserror.ICSERRMakeDir.SetError(oerr)
|
|
|
|
|
|
|
|
// icserror.ICSERRMakeDir.PrintWithCaller(0)
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// gIcsLog.LogFile, oerr = os.OpenFile(gIcsLog.LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
|
|
|
|
|
|
|
// if oerr != nil {
|
|
|
|
|
|
|
|
// //fmt.Println(gIcsLog.LogFileName)
|
|
|
|
|
|
|
|
// icserror.ICSERRFileOpen.SetError(oerr)
|
|
|
|
|
|
|
|
// reterr = icserror.ICSERRFileOpen
|
|
|
|
|
|
|
|
// reterr.PrintWithCaller(0)
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fmt.Println("err != nil")
|
|
|
|
var oerr error
|
|
|
|
var oerr error
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(gIcsLog.LogFileName), 0777)
|
|
|
|
oerr = os.MkdirAll(filepath.Dir(gIcsLog.LogFileName), 0777)
|
|
|
|
if oerr != nil {
|
|
|
|
if oerr != nil {
|
|
|
|