service/vendor/github.com/xxl-job/xxl-job-executor-go/log_handler.go

35 lines
754 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package xxl
import (
"encoding/json"
"net/http"
)
/**
用来日志查询显示到xxl-job-admin后台
*/
type LogHandler func(req *LogReq) *LogRes
//默认返回
func defaultLogHandler(req *LogReq) *LogRes {
return &LogRes{Code: SuccessCode, Msg: "", Content: LogResContent{
FromLineNum: req.FromLineNum,
ToLineNum: 2,
LogContent: "这是日志默认返回说明没有设置LogHandler",
IsEnd: true,
}}
}
//请求错误
func reqErrLogHandler(w http.ResponseWriter, req *LogReq, err error) {
res := &LogRes{Code: FailureCode, Msg: err.Error(), Content: LogResContent{
FromLineNum: req.FromLineNum,
ToLineNum: 0,
LogContent: err.Error(),
IsEnd: true,
}}
str, _ := json.Marshal(res)
_, _ = w.Write(str)
}