日志打印时间

This commit is contained in:
2025-02-07 16:39:02 +08:00
parent 58ca7e22f7
commit 538254f1ba
6 changed files with 19 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
)
@@ -69,21 +70,21 @@ func FetchSubdomainRecord(key string, domain string, Subdomain string) string {
// 获取 DNS 记录
response, err := RetrieveDNSRecords(key, domain)
if err != nil {
fmt.Println("获取 DNS 记录失败:", err)
log.Println("获取 DNS 记录失败:", err)
return "NULL"
}
// 打印完整 JSON 数据
_, err = json.MarshalIndent(response, "", " ")
if err != nil {
fmt.Println("JSON 格式化失败:", err)
log.Println("JSON 格式化失败:", err)
return "NULL"
}
// 只获取指定子域名的信息
for _, record := range response.Reply.ResourceRecords {
if record.Host == Subdomain {
fmt.Printf("RecordID: %s, Host: %s, Type: %s, Value: %s, TTL: %s, Distance: %s\n",
log.Printf("RecordID: %s, Host: %s, Type: %s, Value: %s, TTL: %s, Distance: %s\n",
record.RecordID, record.Host, record.Type, record.Value, record.TTL, parseDistance(record.Distance))
return record.RecordID