Skip to content

Commit

Permalink
client: only log when logger is non-nil
Browse files Browse the repository at this point in the history
  • Loading branch information
wdvxdr1123 committed Mar 2, 2022
1 parent abb3709 commit 7699c32
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,31 @@ func (c *QQClient) SetLogger(logger Logger) {
}

func (c *QQClient) info(msg string, args ...any) {
c.logger.Info(msg, args...)
if c.logger != nil {
c.logger.Info(msg, args...)
}
}

func (c *QQClient) warning(msg string, args ...any) {
c.logger.Warning(msg, args...)
if c.logger != nil {
c.logger.Warning(msg, args...)
}
}

func (c *QQClient) error(msg string, args ...any) {
c.logger.Error(msg, args...)
if c.logger != nil {
c.logger.Error(msg, args...)
}
}

func (c *QQClient) debug(msg string, args ...any) {
c.logger.Debug(msg, args...)
if c.logger != nil {
c.logger.Debug(msg, args...)
}
}

func (c *QQClient) dump(msg string, data []byte, args ...any) {
c.logger.Dump(data, msg, args...)
if c.logger != nil {
c.logger.Dump(data, msg, args...)
}
}

0 comments on commit 7699c32

Please sign in to comment.