Skip to content

Commit ff8db73

Browse files
committed
refactor: 移除调试日志和重复的formatBytes函数
清理代码中的调试打印语句和重复的字节格式化函数
1 parent 2bc4bec commit ff8db73

File tree

3 files changed

+0
-33
lines changed

3 files changed

+0
-33
lines changed

internal/client/cert_deploy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ func (cd *CertDeployer) testNginxConfig() error {
217217
return fmt.Errorf("nginx配置测试失败: %w, 输出: %s", err, string(output))
218218
}
219219

220-
fmt.Println("nginx配置测试通过")
221220
return nil
222221
}
223222

internal/client/client.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func (c *Client) StartConnectNotify() {
115115
for {
116116
select {
117117
case <-c.ctx.Done():
118-
logger.Info("停止监听通知")
119118
return
120119
default:
121120
}
@@ -127,7 +126,6 @@ func (c *Client) StartConnectNotify() {
127126
if err != nil {
128127
// 只在状态变化时打印日志(从连接到断开)
129128
if !c.lastDisconnectLogged.Load() {
130-
logger.Error("建立连接通知失败,等待重连", err)
131129
c.lastDisconnectLogged.Store(true)
132130
}
133131
isConnected.Store(false)
@@ -144,7 +142,6 @@ func (c *Client) StartConnectNotify() {
144142
if err := c.handleNotifyStream(stream); err != nil {
145143
// 只在状态变化时打印日志(从连接到断开)
146144
if !c.lastDisconnectLogged.Load() {
147-
logger.Error("连接中断,等待重连", err)
148145
c.lastDisconnectLogged.Store(true)
149146
}
150147
isConnected.Store(false)
@@ -176,7 +173,6 @@ func (c *Client) handleNotifyStream(stream *connect.ServerStreamForClient[deploy
176173

177174
// 只在状态变化时打印连接成功日志(从断开到连接)
178175
if wasDisconnected && c.lastDisconnectLogged.Load() {
179-
logger.Info("连接服务器成功")
180176
c.lastDisconnectLogged.Store(false)
181177
}
182178

@@ -262,20 +258,6 @@ func (c *Client) downloadFile(downloadURL, filepath string) error {
262258
return nil
263259
}
264260

265-
// formatBytes 格式化字节大小
266-
func formatBytes(bytes int64) string {
267-
const unit = 1024
268-
if bytes < unit {
269-
return fmt.Sprintf("%d B", bytes)
270-
}
271-
div, exp := int64(unit), 0
272-
for n := bytes / unit; n >= unit; n /= unit {
273-
div *= unit
274-
exp++
275-
}
276-
return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp])
277-
}
278-
279261
// min 返回两个 time.Duration 中的较小值
280262
func min(a, b time.Duration) time.Duration {
281263
if a < b {

internal/updater/updater.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,3 @@ func copyFile(src, dst string) error {
477477
}
478478
return os.Chmod(dst, sourceInfo.Mode())
479479
}
480-
481-
// formatBytes 格式化字节大小
482-
func formatBytes(bytes int64) string {
483-
const unit = 1024
484-
if bytes < unit {
485-
return fmt.Sprintf("%d B", bytes)
486-
}
487-
div, exp := int64(unit), 0
488-
for n := bytes / unit; n >= unit; n /= unit {
489-
div *= unit
490-
exp++
491-
}
492-
return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp])
493-
}

0 commit comments

Comments
 (0)