Commit c58a1590 authored by 王明明's avatar 王明明

修改日志区分

parent 3359d2e6
package main package main
import ( import (
"flag"
"fmt" "fmt"
nested "github.com/antonfisher/nested-logrus-formatter" nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/gorilla/mux" "github.com/gorilla/mux"
...@@ -18,6 +19,8 @@ func WelcomeHandler(w http.ResponseWriter, r *http.Request) { ...@@ -18,6 +19,8 @@ func WelcomeHandler(w http.ResponseWriter, r *http.Request) {
} }
func main() { func main() {
logname := flag.String("logname", "akm.log", "日志文件名")
flag.Parse()
logrus.SetLevel(logrus.TraceLevel) logrus.SetLevel(logrus.TraceLevel)
//logrus.SetFormatter(&logrus.TextFormatter{ //logrus.SetFormatter(&logrus.TextFormatter{
// //HideKeys: true, // //HideKeys: true,
...@@ -31,9 +34,10 @@ func main() { ...@@ -31,9 +34,10 @@ func main() {
NoColors: true, NoColors: true,
}) })
logFilePath := util.GetCurrentAbPathByCaller() logFilePath := util.GetCurrentAbPathByCaller()
logFileName := "akm.log" logFileName := *logname
fileName := path.Join(logFilePath, logFileName)
fileName := path.Join(logFilePath, logFileName)
fmt.Println("日志文件路径 ", fileName)
// 写入文件 // 写入文件
//src, err := os.OpenFile(fileName+".log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, os.ModeAppend) //src, err := os.OpenFile(fileName+".log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, os.ModeAppend)
......
export GOPROXY=https://goproxy.cn export GOPROXY=https://goproxy.cn
cd /root/src/js && npm i && nohup /usr/local/bin/node --expose-gc --max-old-space-size=256 --max-new-space-size=1024 run.js > 1.log 2>&1 & cd /root/src/js && npm i && nohup /usr/local/bin/node --expose-gc --max-old-space-size=256 run.js > 1.log 2>&1 &
cd /root/src && go run main.go cd /root/src && go run main.go --logname=$logname
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment