modularize logger (#94)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/shirou/gopsutil/v4/process"
|
||||
|
||||
"github.com/nezhahq/agent/model"
|
||||
"github.com/nezhahq/agent/pkg/logger"
|
||||
"github.com/nezhahq/agent/pkg/monitor/conn"
|
||||
"github.com/nezhahq/agent/pkg/monitor/cpu"
|
||||
"github.com/nezhahq/agent/pkg/monitor/disk"
|
||||
@@ -18,12 +19,13 @@ import (
|
||||
"github.com/nezhahq/agent/pkg/monitor/load"
|
||||
"github.com/nezhahq/agent/pkg/monitor/nic"
|
||||
"github.com/nezhahq/agent/pkg/monitor/temperature"
|
||||
"github.com/nezhahq/agent/pkg/util"
|
||||
)
|
||||
|
||||
var (
|
||||
Version string
|
||||
agentConfig *model.AgentConfig
|
||||
|
||||
printf = logger.DefaultLogger.Printf
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -279,7 +281,3 @@ func tryStat[T any](ctx context.Context, typ uint8, f hostStateFunc[T]) T {
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func printf(format string, v ...interface{}) {
|
||||
util.Printf(agentConfig.Debug, format, v...)
|
||||
}
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/nezhahq/agent/pkg/logger"
|
||||
"github.com/nezhahq/agent/pkg/util"
|
||||
pb "github.com/nezhahq/agent/proto"
|
||||
)
|
||||
@@ -25,7 +26,7 @@ var (
|
||||
|
||||
// UpdateIP 按设置时间间隔更新IP地址的缓存
|
||||
func FetchIP(useIPv6CountryCode bool) *pb.GeoIP {
|
||||
util.Println(agentConfig.Debug, "正在更新本地缓存IP信息")
|
||||
logger.DefaultLogger.Println("正在更新本地缓存IP信息")
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(2)
|
||||
var ipv4, ipv6 string
|
||||
|
||||
Reference in New Issue
Block a user