简单基于DDD重构,并实现机器文件及脚本管理

This commit is contained in:
meilin.huang
2021-05-08 18:00:33 +08:00
parent 50d0dbebb1
commit 5f684a0e48
111 changed files with 2781 additions and 735 deletions

View File

@@ -13,13 +13,8 @@ import (
)
func init() {
// customFormatter := new(log.TextFormatter)
// customFormatter.TimestampFormat = "2006-01-02 15:04:05.000"
// customFormatter.FullTimestamp = true
log.SetFormatter(new(mlog.LogFormatter))
log.SetReportCaller(true)
AfterHandlers = append(AfterHandlers, new(LogInfo))
}
type LogInfo struct {
@@ -36,10 +31,10 @@ func (i *LogInfo) WithLogResp(logResp bool) *LogInfo {
return i
}
func (l *LogInfo) AfterHandle(rc *ReqCtx) {
func LogHandler(rc *ReqCtx) error {
li := rc.LogInfo
if li == nil {
return
return nil
}
lfs := log.Fields{}
@@ -48,14 +43,15 @@ func (l *LogInfo) AfterHandle(rc *ReqCtx) {
lfs["uname"] = la.Username
}
req := rc.Req
req := rc.GinCtx.Request
lfs[req.Method] = req.URL.Path
if err := rc.err; err != nil {
if err := rc.Err; err != nil {
log.WithFields(lfs).Error(getErrMsg(rc, err))
return
return nil
}
log.WithFields(lfs).Info(getLogMsg(rc))
return nil
}
func getLogMsg(rc *ReqCtx) string {