From 2a32689357c24d9e37451e4737f3b254b3929bd0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 26 Oct 2020 20:03:32 +0800 Subject: [PATCH] 1 --- httpserver.go | 5 +++-- syslog.go | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/httpserver.go b/httpserver.go index 6a73010..f4f58fd 100644 --- a/httpserver.go +++ b/httpserver.go @@ -18,15 +18,16 @@ func (this *HttpServer) Init() *HttpServer { this.RegisterHandle("Ops", "selfChecking", func (w http.ResponseWriter,r *http.Request) { w.Write([]byte(`{"errcode":0, "errmsg":"", "health":1, "max_rundelay": 10}`)) }) - fmt.Println("HttpServer.Init\n") + SysLog().Info("HttpServer.Init") return this } func (this *HttpServer) UnInit() { - fmt.Println("HttpServer.UnInit\n") + SysLog().Info("HttpServer.UnInit") } func (this *HttpServer) Start(listen_port int32) { + SysLog().Info("HttpServer.Start listen_port:%d", listen_port) go http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", listen_port), nil) } diff --git a/syslog.go b/syslog.go index 87065e8..edfeb04 100644 --- a/syslog.go +++ b/syslog.go @@ -1,10 +1,12 @@ package f5 -import "os" -import "sync" -import "time" -import "fmt" -import "q5" +import ( + "os" + "sync" + "time" + "fmt" + "q5" +) const ( LOG_DEBUG = 0 @@ -26,7 +28,6 @@ type LogMsgNode struct { type SysLog_ struct { logLevel int32 - debuging bool topNode *LogMsgNode botNode *LogMsgNode msgMutex sync.Mutex @@ -96,7 +97,7 @@ func (this *SysLog_) addLog(category string, format string, args ...interface{}) p.logMsg = time.Now().Format("2006-01-02 15:04:05") + category + " " + fmt.Sprintf(format, args...) + "\n" - if this.debuging { + if q5.Debug() { fmt.Print(p.logMsg) } this.msgMutex.Lock()