优化日志
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user