优化日志

This commit is contained in:
yml2213
2026-06-19 13:02:28 +08:00
parent 59b9dd12ef
commit 878daa4ab8
6 changed files with 419 additions and 8 deletions
+24
View File
@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"io"
"net/http"
"sync"
"time"
@@ -21,6 +22,11 @@ type appPaths struct {
FontFiles []string
}
type TraceConfig struct {
Enabled bool
MaxBodyBytes int
}
type Account struct {
Name string `json:"name"`
Password string `json:"password"`
@@ -82,6 +88,7 @@ type appState struct {
paths appPaths
client *DouyuClient
logs *memoryLogStore
trace *traceRecorder
accountsMu sync.RWMutex
accounts []Account
@@ -103,6 +110,23 @@ type appState struct {
type DouyuClient struct {
httpClient *http.Client
timeAPIURL string
trace *traceRecorder
}
type traceRecorder struct {
enabled bool
maxBodyBytes int
writer *asyncLogWriter
filePath string
seq uint64
}
type asyncLogWriter struct {
dst io.Writer
ch chan []byte
wg sync.WaitGroup
closed uint32
dropped uint64
}
type ExchangeAttempt struct {