This commit is contained in:
aozhiwei 2020-10-26 20:03:32 +08:00
parent 924d5ca12a
commit 2a32689357
2 changed files with 11 additions and 9 deletions

View File

@ -18,15 +18,16 @@ func (this *HttpServer) Init() *HttpServer {
this.RegisterHandle("Ops", "selfChecking", func (w http.ResponseWriter,r *http.Request) { this.RegisterHandle("Ops", "selfChecking", func (w http.ResponseWriter,r *http.Request) {
w.Write([]byte(`{"errcode":0, "errmsg":"", "health":1, "max_rundelay": 10}`)) w.Write([]byte(`{"errcode":0, "errmsg":"", "health":1, "max_rundelay": 10}`))
}) })
fmt.Println("HttpServer.Init\n") SysLog().Info("HttpServer.Init")
return this return this
} }
func (this *HttpServer) UnInit() { func (this *HttpServer) UnInit() {
fmt.Println("HttpServer.UnInit\n") SysLog().Info("HttpServer.UnInit")
} }
func (this *HttpServer) Start(listen_port int32) { 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) go http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", listen_port), nil)
} }

View File

@ -1,10 +1,12 @@
package f5 package f5
import "os" import (
import "sync" "os"
import "time" "sync"
import "fmt" "time"
import "q5" "fmt"
"q5"
)
const ( const (
LOG_DEBUG = 0 LOG_DEBUG = 0
@ -26,7 +28,6 @@ type LogMsgNode struct {
type SysLog_ struct { type SysLog_ struct {
logLevel int32 logLevel int32
debuging bool
topNode *LogMsgNode topNode *LogMsgNode
botNode *LogMsgNode botNode *LogMsgNode
msgMutex sync.Mutex 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") + p.logMsg = time.Now().Format("2006-01-02 15:04:05") +
category + " " + category + " " +
fmt.Sprintf(format, args...) + "\n" fmt.Sprintf(format, args...) + "\n"
if this.debuging { if q5.Debug() {
fmt.Print(p.logMsg) fmt.Print(p.logMsg)
} }
this.msgMutex.Lock() this.msgMutex.Lock()