1
This commit is contained in:
parent
72619df2c1
commit
35c7b10247
22
app.go
22
app.go
@ -23,6 +23,9 @@ type App interface {
|
|||||||
GetNowSeconds() int64
|
GetNowSeconds() int64
|
||||||
GetNowMillis() int64
|
GetNowMillis() int64
|
||||||
GetNowNano() int64
|
GetNowNano() int64
|
||||||
|
GetTimeOffset() int32
|
||||||
|
SetTimeOffset(int32)
|
||||||
|
GetLocation() *time.Location
|
||||||
RegisterMainThreadCb(func())
|
RegisterMainThreadCb(func())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +53,8 @@ type app struct {
|
|||||||
chGoLoopWait chan int64
|
chGoLoopWait chan int64
|
||||||
nowTime time.Time
|
nowTime time.Time
|
||||||
nowUnixNano int64
|
nowUnixNano int64
|
||||||
|
timeOffset int32
|
||||||
|
location *time.Location
|
||||||
imMsgHandlers [1024]func(q5.Args)
|
imMsgHandlers [1024]func(q5.Args)
|
||||||
maxRunDelay int64
|
maxRunDelay int64
|
||||||
maxScheduleTime int64
|
maxScheduleTime int64
|
||||||
@ -60,6 +65,7 @@ type app struct {
|
|||||||
func (this *app) init(userApp UserApp) {
|
func (this *app) init(userApp UserApp) {
|
||||||
this.userApp = userApp
|
this.userApp = userApp
|
||||||
this.nowTime = time.Now()
|
this.nowTime = time.Now()
|
||||||
|
this.SetTimeOffset(0)
|
||||||
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
||||||
_timer = new(timer)
|
_timer = new(timer)
|
||||||
_timer.init()
|
_timer.init()
|
||||||
@ -223,6 +229,22 @@ func (this *app) GetNowNano() int64 {
|
|||||||
return this.nowUnixNano
|
return this.nowUnixNano
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *app) GetTimeOffset() int32 {
|
||||||
|
return this.timeOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *app) SetTimeOffset(offset int32) {
|
||||||
|
this.timeOffset = offset
|
||||||
|
this.location = time.FixedZone("UTC-f5", int(offset))
|
||||||
|
if this.location == nil {
|
||||||
|
panic("SetTimeOffset error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *app) GetLocation() *time.Location {
|
||||||
|
return this.location
|
||||||
|
}
|
||||||
|
|
||||||
func (this *app) outputRuningLog() {
|
func (this *app) outputRuningLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ func (this *sysLog) addLog(category int32, prefixStr string,
|
|||||||
format string, args ...interface{}) {
|
format string, args ...interface{}) {
|
||||||
p := &logMsgNode{}
|
p := &logMsgNode{}
|
||||||
p.category = category
|
p.category = category
|
||||||
p.logMsg = time.Now().Format("2006-01-02 15:04:05") +
|
p.logMsg = q5.FormatUnixDateTime(_app.GetNowSeconds(), _app.GetLocation()) +
|
||||||
prefixStr + " " +
|
prefixStr + " " +
|
||||||
fmt.Sprintf(format, args...) + "\n"
|
fmt.Sprintf(format, args...) + "\n"
|
||||||
if category == LOG_INFO {
|
if category == LOG_INFO {
|
||||||
@ -130,7 +130,9 @@ func (this *sysLog) goSaveToFile() {
|
|||||||
this.msgMutex.Unlock()
|
this.msgMutex.Unlock()
|
||||||
if workNode != nil {
|
if workNode != nil {
|
||||||
logDir := fmt.Sprintf(SYS_LOG_ROOT, GetApp().GetPkgName())
|
logDir := fmt.Sprintf(SYS_LOG_ROOT, GetApp().GetPkgName())
|
||||||
fileName := fmt.Sprintf(TGLOG_FILENAME, os.Getpid(), time.Now().Format("20060102"))
|
fileName := fmt.Sprintf(TGLOG_FILENAME,
|
||||||
|
os.Getpid(),
|
||||||
|
q5.FormatUnixDateEx(_app.GetNowSeconds(), _app.GetLocation()))
|
||||||
q5.ForceCreateDir(logDir)
|
q5.ForceCreateDir(logDir)
|
||||||
if f, err := os.OpenFile(logDir+fileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666); err == nil {
|
if f, err := os.OpenFile(logDir+fileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666); err == nil {
|
||||||
for workNode != nil {
|
for workNode != nil {
|
||||||
|
6
tglog.go
6
tglog.go
@ -62,7 +62,7 @@ func (this *tgLog) AddTrackLogEx(
|
|||||||
} {
|
} {
|
||||||
AccountId: accountId,
|
AccountId: accountId,
|
||||||
Type: "track",
|
Type: "track",
|
||||||
Time: time.Now().Format("2006-01-02 15:04:05"),
|
Time: q5.FormatUnixDateTime(_app.GetNowSeconds(), _app.GetLocation()),
|
||||||
EventName: eventName,
|
EventName: eventName,
|
||||||
Ip: remoteAddr,
|
Ip: remoteAddr,
|
||||||
Properties: prop,
|
Properties: prop,
|
||||||
@ -108,7 +108,9 @@ func (this *tgLog) goSaveToFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *tgLog) getLogFile(gameId int32) *os.File {
|
func (this *tgLog) getLogFile(gameId int32) *os.File {
|
||||||
fileName := fmt.Sprintf(TGLOG_FILENAME, os.Getpid(), time.Now().Format("20060102"))
|
fileName := fmt.Sprintf(TGLOG_FILENAME,
|
||||||
|
os.Getpid(),
|
||||||
|
q5.FormatUnixDateEx(_app.GetNowSeconds(), _app.GetLocation()))
|
||||||
logDir := ""
|
logDir := ""
|
||||||
if this.isPolyLog {
|
if this.isPolyLog {
|
||||||
logDir = fmt.Sprintf(POLY_TGLOG_ROOT, _app.GetPkgName(), gameId)
|
logDir = fmt.Sprintf(POLY_TGLOG_ROOT, _app.GetPkgName(), gameId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user