feat: 添加更多debug日志、checker url可控化

This commit is contained in:
Mmx233
2022-03-02 23:06:29 +08:00
parent fc94672038
commit 53f813c230
8 changed files with 41 additions and 16 deletions

View File

@@ -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,
})

View File

@@ -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 += "/"
}