Skip to content

Commit

Permalink
Refactor: use proper const name.
Browse files Browse the repository at this point in the history
  • Loading branch information
keuin committed Jul 14, 2023
1 parent 2ace07d commit 4908265
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bilibili/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down
4 changes: 2 additions & 2 deletions recording/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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...")
Expand Down

0 comments on commit 4908265

Please sign in to comment.