feat: 添加更多debug日志、checker url可控化
This commit is contained in:
@@ -5,14 +5,28 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type checker struct{}
|
||||
type checker struct {
|
||||
url string
|
||||
set bool
|
||||
}
|
||||
|
||||
var Checker checker
|
||||
var Checker = checker{
|
||||
url: "https://www.baidu.com/",
|
||||
}
|
||||
|
||||
func (a *checker) SetUrl(url string) {
|
||||
if a.set {
|
||||
return
|
||||
}
|
||||
a.url = url
|
||||
a.set = true
|
||||
}
|
||||
|
||||
// NetOk 网络状况检查
|
||||
func (a *checker) NetOk(transport *http.Transport) bool {
|
||||
Log.Debug("GET ", a.url)
|
||||
res, e := tool.HTTP.GetReader(&tool.GetRequest{
|
||||
Url: "https://www.baidu.com/",
|
||||
Url: a.url,
|
||||
Redirect: false,
|
||||
Transport: transport,
|
||||
})
|
||||
|
||||
@@ -26,7 +26,7 @@ func (c *loG) Init(debug, logFile, outPut bool, path string) error {
|
||||
c.timeStamp = time.Now().Format("2006.01.02-15.04.05")
|
||||
|
||||
//日志路径初始化与处理
|
||||
if c.DebugMode {
|
||||
if c.DebugMode && c.WriteFile {
|
||||
if !strings.HasSuffix(path, "/") {
|
||||
path += "/"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user