summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-07-14 22:29:35 +0800
committerKeuin <[email protected]>2023-07-14 22:29:35 +0800
commit49082656b79cea1d5ea21fe92564eaddd9b5843a (patch)
treee0d98cfd17e3c0fe044424d32396068b25e4096d
parent2ace07d2d88c01a56b4d0f3194bd74a518a769c8 (diff)
Refactor: use proper const name.0.4.0
-rw-r--r--bilibili/client.go6
-rw-r--r--logging/logger.go20
-rw-r--r--recording/watcher.go4
3 files changed, 15 insertions, 15 deletions
diff --git a/bilibili/client.go b/bilibili/client.go
index 17a42d6..4abad60 100644
--- a/bilibili/client.go
+++ b/bilibili/client.go
@@ -13,8 +13,8 @@ import (
)
const (
- // kUserAgent: the default user-agent header to use when communicating with bilibili.
- kUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
+ // userAgent: the default user-agent header to use when communicating with bilibili.
+ userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
)
@@ -41,7 +41,7 @@ func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, log
return &Bilibili{
logger: logger,
- userAgent: kUserAgent,
+ userAgent: userAgent,
http: http.DefaultClient,
ctx: ctx,
netTypes: nets,
diff --git a/logging/logger.go b/logging/logger.go
index 9724c2f..f5de019 100644
--- a/logging/logger.go
+++ b/logging/logger.go
@@ -21,21 +21,21 @@ type Logger struct {
}
const (
- kDebug = "DEBUG"
- kInfo = "INFO"
- kWarning = "WARNING"
- kError = "ERROR"
- kFatal = "FATAL"
+ levelDebug = "DEBUG"
+ levelInfo = "INFO"
+ levelWarning = "WARNING"
+ levelError = "ERROR"
+ levelFatal = "FATAL"
)
func NewWrappedLogger(delegate *log.Logger, name string) Logger {
return Logger{
delegate: delegate,
- debugHeader: fmt.Sprintf("[%v][%v]", name, kDebug),
- infoHeader: fmt.Sprintf("[%v][%v]", name, kInfo),
- warningHeader: fmt.Sprintf("[%v][%v]", name, kWarning),
- errorHeader: fmt.Sprintf("[%v][%v]", name, kError),
- fatalHeader: fmt.Sprintf("[%v][%v]", name, kFatal),
+ debugHeader: fmt.Sprintf("[%v][%v]", name, levelDebug),
+ infoHeader: fmt.Sprintf("[%v][%v]", name, levelInfo),
+ warningHeader: fmt.Sprintf("[%v][%v]", name, levelWarning),
+ errorHeader: fmt.Sprintf("[%v][%v]", name, levelError),
+ fatalHeader: fmt.Sprintf("[%v][%v]", name, levelFatal),
}
}
diff --git a/recording/watcher.go b/recording/watcher.go
index 181e0fc..0e4b459 100644
--- a/recording/watcher.go
+++ b/recording/watcher.go
@@ -24,7 +24,7 @@ type liveInfo struct {
}
const (
- kHeartBeatInterval = 30 * time.Second
+ heartBeatInterval = 30 * time.Second
)
// watch monitors live room status by subscribing messages from Bilibili danmaku server,
@@ -80,7 +80,7 @@ func watch(
}
// create heartbeat timer
- heartBeatTimer := time.NewTicker(kHeartBeatInterval)
+ heartBeatTimer := time.NewTicker(heartBeatInterval)
defer func() { heartBeatTimer.Stop() }()
logger.Info("Checking initial live status...")