V2.7 增加agent执行器

This commit is contained in:
georgehao
2019-07-03 22:31:27 +08:00
parent c3a89e9243
commit 37fb659c4e
48 changed files with 2832 additions and 513 deletions

41
agent/server/logs.go Normal file
View File

@@ -0,0 +1,41 @@
/************************************************************
** @Description: log
** @Author: haodaquan
** @Date: 2018-08-22 23:00
** @Last Modified by: haodaquan
** @Last Modified time: 2018-08-22 23:00
*************************************************************/
package server
import (
"fmt"
"log"
"net/http"
"strings"
"time"
)
var Env string
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
//http相关
func WriteLog(r *http.Request, t time.Time, match string, pattern string) {
if C.AppMode != "prod" {
d := time.Now().Sub(t)
l := fmt.Sprintf("[ACCESS] | % -10s | % -40s | % -16s | % -10s | % -40s |",
r.Method, r.URL.Path, d.String(), match, pattern)
log.Println(l)
}
}
//系统运行相关
func NLog(level string, value ...interface{}) {
if strings.Contains(C.LogLevel, level) || C.LogLevel == "ALL" {
log.Println("["+level+"]", value)
return
}
}