Skip to content

Commit c22815f

Browse files
authored
chore (log): rename logging methods to *f suffix (#156)
1 parent 8479db4 commit c22815f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

client/log.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,49 @@ func (c *QQClient) SetLogger(logger log.Logger) {
1515

1616
func (c *QQClient) info(msg string, args ...any) {
1717
if c.logger != nil {
18-
c.logger.Info(msg, args...)
18+
c.logger.Infof(msg, args...)
1919
}
2020
}
2121

2222
func (c *QQClient) infoln(msgs ...any) {
2323
if c.logger != nil {
24-
c.logger.Info(fmt.Sprint(msgs...))
24+
c.logger.Infof(fmt.Sprint(msgs...))
2525
}
2626
}
2727

2828
func (c *QQClient) warning(msg string, args ...any) {
2929
if c.logger != nil {
30-
c.logger.Warning(log.Getcaller(msg), args...)
30+
c.logger.Warningf(log.Getcaller(msg), args...)
3131
}
3232
}
3333

3434
func (c *QQClient) warningln(msgs ...any) {
3535
if c.logger != nil {
36-
c.logger.Warning(log.Getcaller(fmt.Sprint(msgs...)))
36+
c.logger.Warningf(log.Getcaller(fmt.Sprint(msgs...)))
3737
}
3838
}
3939

4040
func (c *QQClient) error(msg string, args ...any) {
4141
if c.logger != nil {
42-
c.logger.Error(log.Getcaller(msg), args...)
42+
c.logger.Errorf(log.Getcaller(msg), args...)
4343
}
4444
}
4545

4646
func (c *QQClient) errorln(msgs ...any) {
4747
if c.logger != nil {
48-
c.logger.Error(log.Getcaller(fmt.Sprint(msgs...)))
48+
c.logger.Errorf(log.Getcaller(fmt.Sprint(msgs...)))
4949
}
5050
}
5151

5252
func (c *QQClient) debug(msg string, args ...any) {
5353
if c.logger != nil {
54-
c.logger.Debug(log.Getcaller(msg), args...)
54+
c.logger.Debugf(log.Getcaller(msg), args...)
5555
}
5656
}
5757

5858
func (c *QQClient) debugln(msgs ...any) {
5959
if c.logger != nil {
60-
c.logger.Debug(log.Getcaller(fmt.Sprint(msgs...)))
60+
c.logger.Debugf(log.Getcaller(fmt.Sprint(msgs...)))
6161
}
6262
}
6363

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,19 @@ type protocolLogger struct{}
183183

184184
const fromProtocol = "Lgr -> "
185185

186-
func (p protocolLogger) Info(format string, arg ...any) {
186+
func (p protocolLogger) Infof(format string, arg ...any) {
187187
logger.Infof(fromProtocol+format, arg...)
188188
}
189189

190-
func (p protocolLogger) Warning(format string, arg ...any) {
190+
func (p protocolLogger) Warningf(format string, arg ...any) {
191191
logger.Warnf(fromProtocol+format, arg...)
192192
}
193193

194-
func (p protocolLogger) Debug(format string, arg ...any) {
194+
func (p protocolLogger) Debugf(format string, arg ...any) {
195195
logger.Debugf(fromProtocol+format, arg...)
196196
}
197197

198-
func (p protocolLogger) Error(format string, arg ...any) {
198+
func (p protocolLogger) Errorf(format string, arg ...any) {
199199
logger.Errorf(fromProtocol+format, arg...)
200200
}
201201

utils/log/log.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
)
77

88
type Logger interface {
9-
Info(format string, args ...any)
10-
Warning(format string, args ...any)
11-
Error(format string, args ...any)
12-
Debug(format string, args ...any)
9+
Infof(format string, args ...any)
10+
Warningf(format string, args ...any)
11+
Errorf(format string, args ...any)
12+
Debugf(format string, args ...any)
1313
Dump(dumped []byte, format string, args ...any)
1414
}
1515

0 commit comments

Comments
 (0)