diff --git a/app.go b/app.go index b0217c6..50ef174 100644 --- a/app.go +++ b/app.go @@ -60,10 +60,10 @@ func (this *app) init(userApp UserApp) { atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano()) _timer = &Timer{} _timer.init() - _SysLog = new(SysLog_) - _SysLog.Init() - _TgLog = new(TGLog_) - _TgLog.Init() + _sysLog = new(SysLog_) + _sysLog.init() + _tgLog = new(TGLog_) + _tgLog.init() { var tmpNodeId, tmpInstanceId int flag.IntVar(&tmpNodeId, "n", 0, "node id") @@ -76,7 +76,7 @@ func (this *app) init(userApp UserApp) { this.chGoLoopTimerExit = make(chan int) this.chGoLoopWait = make(chan int64) this.outputRuningLog() - SysLog().Info("node_id:%d instance_id:%d pid:%d", + GetSysLog().Info("node_id:%d instance_id:%d pid:%d", this.nodeId, this.instanceId, os.Getpid()) @@ -224,7 +224,7 @@ func (this *app) installTimer() { GetTimer().SetInterval(1000 * 60, func (ev int32, params *q5.Args) { if ev == q5.TIMER_EXEC_EVENT { - SysLog().Info("max_run_delay:%d max_schedule_time:%d", + GetSysLog().Info("max_run_delay:%d max_schedule_time:%d", _app.maxRunDelay, _app.maxScheduleTime) _app.maxRunDelay = 0 diff --git a/export.go b/export.go index e9fd081..eb4ff0c 100644 --- a/export.go +++ b/export.go @@ -2,19 +2,19 @@ package f5 var _app *app var _timer *Timer -var _SysLog *SysLog_ -var _TgLog *TGLog_ +var _sysLog *SysLog_ +var _tgLog *TGLog_ func GetTimer() *Timer { return _timer } -func SysLog() *SysLog_ { - return _SysLog +func GetSysLog() *SysLog_ { + return _sysLog } -func TgLog() *TGLog_ { - return _TgLog +func GteTgLog() *TGLog_ { + return _tgLog } func GetApp() App { diff --git a/httpserver.go b/httpserver.go index 81d2b7e..d4bd48b 100644 --- a/httpserver.go +++ b/httpserver.go @@ -40,13 +40,13 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe func (c *Context) { c.Response(`{"errcode":0, "errmsg":"", "healthy":1, "max_rundelay":10}`) }) - SysLog().Info("HttpServer.Init") + GetSysLog().Info("HttpServer.Init") if logOutputTime > 0 { GetTimer().SetInterval( logOutputTime, func (ev int32, params *q5.Args) { if ev == q5.TIMER_EXEC_EVENT { - SysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d", + GetSysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d", serviceName, this.maxHandleTime, this.totalRequestTimes, @@ -62,13 +62,13 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe } func (this *HttpServer) UnInit() { - SysLog().Info("HttpServer.UnInit") + GetSysLog().Info("HttpServer.UnInit") } func (this *HttpServer) Start(listen_port int32) { atomic.AddInt64(&this.totalRequestTimes, 1) this.installGlobalMiddleware() - SysLog().Info("HttpServer.Start listen_port:%d", listen_port) + GetSysLog().Info("HttpServer.Start listen_port:%d", listen_port) go http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", listen_port), nil) } @@ -85,7 +85,7 @@ func (this *HttpServer) dispatchRequest(c *Context) { } atomic.AddInt64(&this.okTimes, 1) if err := recover(); err != nil { - SysLog().Error("handle name:%s error:%s", handleName, err) + GetSysLog().Error("handle name:%s error:%s", handleName, err) c.Response(`{"errcode":500, "errmsg":"server internal error"}`) } }() diff --git a/syslog.go b/syslog.go index eaaf25a..0273933 100644 --- a/syslog.go +++ b/syslog.go @@ -34,12 +34,12 @@ type SysLog_ struct { chGoSaveExit chan int } -func (this *SysLog_) Init() { +func (this *SysLog_) init() { this.chGoSaveExit = make(chan int) go this.goSaveToFile() } -func (this *SysLog_) UnInit() { +func (this *SysLog_) unInit() { this.chGoSaveExit <- 1 } diff --git a/tglog.go b/tglog.go index 97e82ab..c8a8d81 100644 --- a/tglog.go +++ b/tglog.go @@ -24,12 +24,12 @@ type TGLog_ struct { chGoSaveExit chan int } -func (this *TGLog_) Init() { +func (this *TGLog_) init() { this.chGoSaveExit = make(chan int) //go this.goSaveToFile() } -func (this *TGLog_) UnInit() { +func (this *TGLog_) unInit() { this.chGoSaveExit <- 1 }