支持自定义日志,优化数据返回

This commit is contained in:
duanhf2012
2020-03-31 18:29:00 +08:00
parent 9e74d2bf2a
commit 5344da1276
5 changed files with 50 additions and 33 deletions

View File

@@ -4,8 +4,10 @@ import (
"fmt"
"github.com/duanhf2012/origin/cluster"
"github.com/duanhf2012/origin/console"
"github.com/duanhf2012/origin/log"
"github.com/duanhf2012/origin/service"
"io/ioutil"
syslog "log"
"os"
"os/signal"
"strconv"
@@ -84,6 +86,7 @@ func initNode(id int){
}
func Start() {
SetSysLog("debug","./",syslog.Lshortfile|syslog.LstdFlags)
console.RegisterCommand("start",startNode)
console.RegisterCommand("stop",stopNode)
err := console.Run(os.Args)
@@ -131,4 +134,9 @@ func GetService(servicename string) service.IService {
func SetConfigDir(configdir string){
cluster.SetConfigDir(configdir)
}
}
func SetSysLog(strLevel string, pathname string, flag int){
logs,_:= log.New(strLevel,pathname,flag)
log.Export(logs)
}