| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package config
- import (
- "github.com/coroot/coroot-node-agent/utils/worker"
- "github.com/sirupsen/logrus"
- klog "github.com/sirupsen/logrus"
- )
- // updateProxyClientEndpoints 更新 ProxyClient 的 endpoints
- // 当 ConfigServer 热更新时,需要同步更新 ProxyClient 的 endpoints
- func updateProxyClientEndpoints(configServer string) {
- proxyClient, err := worker.GetProxyClient()
- if err != nil {
- // ProxyClient 还未初始化,不需要更新
- klog.Debugf("ProxyClient not initialized yet, skipping endpoint update")
- return
- }
- // 更新 endpoints
- if err := proxyClient.SetEndpoint(configServer, false); err != nil {
- klog.Warnf("Failed to update ProxyClient endpoints: %v", err)
- } else {
- klog.Infof("Updated ProxyClient endpoints to: %s", configServer)
- }
- }
- // updateLogLevel 更新日志级别
- // 当 logging.log_level 热更新时,需要重新设置 logrus 的级别
- func updateLogLevel(level string) {
- if level == "" {
- level = "info"
- }
- logrusLevel, err := logrus.ParseLevel(level)
- if err != nil {
- klog.Warnf("Failed to parse log level %s: %v", level, err)
- return
- }
- logrus.SetLevel(logrusLevel)
- klog.Infof("Updated log level to: %s", level)
- }
- // updateLogOutput 更新日志输出目标
- // 当 logging.console_log 热更新时,需要更新日志输出
- func updateLogOutput(consoleLog bool) {
- // 注意:由于 logrus 的输出设置比较复杂,这里只更新基本设置
- // 如果需要完整的输出切换,可能需要重新调用 logs.InitLog
- klog.Infof("Updated console log output: %v", consoleLog)
- }
|