feat: 将日志级别从 Info 调整为 Debug,以减少生产环境中的日志噪声

This commit is contained in:
ryan
2026-03-13 16:33:56 +08:00
parent 8aef32c0cc
commit 4b4b6bf80e
6 changed files with 67 additions and 39 deletions
+5 -5
View File
@@ -30,7 +30,7 @@ func New(baseURL string, token string, timeout time.Duration) *Client {
}
func (c *Client) RegisterNode(ctx context.Context, payload protocol.NodePayload) (*protocol.RegisterNodeResponse, error) {
slog.Info("http register node request", "node_id", payload.NodeID, "current_version", payload.CurrentVersion)
slog.Debug("http register node request", "node_id", payload.NodeID, "current_version", payload.CurrentVersion)
resp := protocol.APIResponse[protocol.RegisterNodeResponse]{}
if err := c.postJSON(ctx, "/api/agent/nodes/register", payload, &resp); err != nil {
return nil, err
@@ -38,7 +38,7 @@ func (c *Client) RegisterNode(ctx context.Context, payload protocol.NodePayload)
if !resp.Success {
return nil, errors.New(resp.Message)
}
slog.Info("http register node response", "node_id", resp.Data.NodeID)
slog.Debug("http register node response", "node_id", resp.Data.NodeID)
return &resp.Data, nil
}
@@ -64,18 +64,18 @@ func (c *Client) GetActiveConfig(ctx context.Context) (*protocol.ActiveConfigRes
if !resp.Success {
return nil, errors.New(resp.Message)
}
slog.Info("http get active config response", "version", resp.Data.Version, "checksum", resp.Data.Checksum, "support_files", len(resp.Data.SupportFiles))
slog.Debug("http get active config response", "version", resp.Data.Version, "checksum", resp.Data.Checksum, "support_files", len(resp.Data.SupportFiles))
return &resp.Data, nil
}
func (c *Client) ReportApplyLog(ctx context.Context, payload protocol.ApplyLogPayload) error {
slog.Info("http report apply log request", "node_id", payload.NodeID, "version", payload.Version, "result", payload.Result)
slog.Debug("http report apply log request", "node_id", payload.NodeID, "version", payload.Version, "result", payload.Result)
return c.postJSON(ctx, "/api/agent/apply-logs", payload, nil)
}
func (c *Client) SetToken(token string) {
c.token = strings.TrimSpace(token)
slog.Info("http client token updated")
slog.Debug("http client token updated")
}
func (c *Client) getJSON(ctx context.Context, path string, target any) error {