mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化日志
This commit is contained in:
@@ -23,11 +23,11 @@ func init() {
|
|||||||
|
|
||||||
//OnInit ...
|
//OnInit ...
|
||||||
func (ws *SubNet1_Service1) OnInit() error {
|
func (ws *SubNet1_Service1) OnInit() error {
|
||||||
|
originhttp.Post("", ws.HTTP_UserIntegralInfo)
|
||||||
originhttp.Post(" / aaa/bb/ :user/:pass/", ws.HTTP_UserIntegralInfo)
|
|
||||||
originhttp.Post(" /aaa/bbb", ws.Test)
|
originhttp.Post(" /aaa/bbb", ws.Test)
|
||||||
originhttp.Get(" /aaa/bbb", ws.HTTP_UserIntegralInfo)
|
originhttp.Get("/Login/bbb", ws.HTTP_UserIntegralInfo)
|
||||||
originhttp.SetStaticResource(originhttp.METHOD_GET, "/file/", "d:\\")
|
originhttp.SetStaticResource(originhttp.METHOD_GET, "/file/", "d:\\")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
||||||
"github.com/duanhf2012/origin/cluster"
|
"github.com/duanhf2012/origin/cluster"
|
||||||
"github.com/duanhf2012/origin/originnode"
|
"github.com/duanhf2012/origin/originnode"
|
||||||
"github.com/duanhf2012/origin/sysservice/originhttp"
|
"github.com/duanhf2012/origin/sysservice/originhttp"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"path": "."
|
"path": "."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "D:\\GOPATH\\src\\github.com\\duanhf2012\\origin"
|
"path": "D:\\GOPATH\\src\\github.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
|
|||||||
@@ -115,25 +115,25 @@ func (slf *HttpRequest) Query(key string) (string, bool) {
|
|||||||
|
|
||||||
func Request(method HTTP_METHOD, url string, handle HttpHandle) error {
|
func Request(method HTTP_METHOD, url string, handle HttpHandle) error {
|
||||||
fnpath := runtime.FuncForPC(reflect.ValueOf(handle).Pointer()).Name()
|
fnpath := runtime.FuncForPC(reflect.ValueOf(handle).Pointer()).Name()
|
||||||
fmt.Print(fnpath)
|
|
||||||
sidx := strings.LastIndex(fnpath, "*")
|
sidx := strings.LastIndex(fnpath, "*")
|
||||||
if sidx == -1 {
|
if sidx == -1 {
|
||||||
return errors.New(fmt.Sprintf("http post func path is error, %s", fnpath))
|
return errors.New(fmt.Sprintf("http post func path is error, %s\n", fnpath))
|
||||||
}
|
}
|
||||||
|
|
||||||
eidx := strings.LastIndex(fnpath, "-fm")
|
eidx := strings.LastIndex(fnpath, "-fm")
|
||||||
if sidx == -1 {
|
if sidx == -1 {
|
||||||
return errors.New(fmt.Sprintf("http post func path is error, %s", fnpath))
|
return errors.New(fmt.Sprintf("http post func path is error, %s\n", fnpath))
|
||||||
}
|
}
|
||||||
callpath := fnpath[sidx+1 : eidx]
|
callpath := fnpath[sidx+1 : eidx]
|
||||||
ridx := strings.LastIndex(callpath, ")")
|
ridx := strings.LastIndex(callpath, ")")
|
||||||
if ridx == -1 {
|
if ridx == -1 {
|
||||||
return errors.New(fmt.Sprintf("http post func path is error, %s", fnpath))
|
return errors.New(fmt.Sprintf("http post func path is error, %s\n", fnpath))
|
||||||
}
|
}
|
||||||
|
|
||||||
hidx := strings.LastIndex(callpath, "HTTP_")
|
hidx := strings.LastIndex(callpath, "HTTP_")
|
||||||
if hidx == -1 {
|
if hidx == -1 {
|
||||||
return errors.New(fmt.Sprintf("http post func not contain HTTP_, %s", fnpath))
|
return errors.New(fmt.Sprintf("http post func not contain HTTP_, %s\n", fnpath))
|
||||||
}
|
}
|
||||||
|
|
||||||
callpath = strings.ReplaceAll(callpath, ")", "")
|
callpath = strings.ReplaceAll(callpath, ")", "")
|
||||||
@@ -224,7 +224,7 @@ func (slf *ServeHTTPRouterMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
timeFuncPass := time.Since(timeFuncStart)
|
timeFuncPass := time.Since(timeFuncStart)
|
||||||
if bPrintRequestTime {
|
if bPrintRequestTime {
|
||||||
service.GetLogger().Printf(service.LEVER_INFO, "HttpServer Time : %s url : %s", timeFuncPass, strCallPath)
|
service.GetLogger().Printf(service.LEVER_INFO, "HttpServer Time : %s url : %s\n", timeFuncPass, strCallPath)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeRespone(w, http.StatusBadRequest, fmt.Sprint(err))
|
writeRespone(w, http.StatusBadRequest, fmt.Sprint(err))
|
||||||
|
|||||||
Reference in New Issue
Block a user