Skip to content

Commit

Permalink
use named logger & fix warn log k/v
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Aug 7, 2024
1 parent d7bce1c commit efc35b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion _examples/discordgo/commands.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"log/slog"

"github.com/bwmarrin/discordgo"
"github.com/disgoorg/log"
)
Expand Down Expand Up @@ -76,6 +78,6 @@ var commands = []*discordgo.ApplicationCommand{

func registerCommands(s *discordgo.Session) {
if _, err := s.ApplicationCommandBulkOverwrite(s.State.User.ID, GuildId, commands); err != nil {
log.Warn(err)
log.Warn("Failed to register commands", slog.Any("err", err))
}
}
5 changes: 3 additions & 2 deletions disgolink/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"sync"
"time"

"github.com/disgoorg/disgolink/v3/lavalink"
"github.com/gorilla/websocket"

"github.com/disgoorg/disgolink/v3/lavalink"
)

type Status string
Expand Down Expand Up @@ -236,7 +237,7 @@ func (n *nodeImpl) open(ctx context.Context, reconnecting bool) error {
if ready.Resumed {
n.logger.InfoContext(ctx, "successfully resumed session", slog.String("session_id", n.config.SessionID))
if err = n.syncPlayers(ctx); err != nil {
n.logger.Warn("failed to sync players: ", err)
n.logger.Warn("failed to sync players: ", slog.Any("err", err))
}
} else {
n.logger.Warn("failed to resume session", slog.String("session_id", n.config.SessionID))
Expand Down
5 changes: 3 additions & 2 deletions disgolink/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"log/slog"
"time"

"github.com/disgoorg/disgolink/v3/lavalink"
"github.com/disgoorg/snowflake/v2"

"github.com/disgoorg/disgolink/v3/lavalink"
)

var ErrPlayerNoNode = errors.New("player has no node")
Expand Down Expand Up @@ -37,7 +38,7 @@ type Player interface {

func NewPlayer(logger *slog.Logger, lavalink Client, node Node, guildID snowflake.ID) Player {
return &playerImpl{
logger: logger,
logger: logger.With(slog.String("name", "player"), slog.String("guild_id", guildID.String())),
lavalink: lavalink,
node: node,
guildID: guildID,
Expand Down

0 comments on commit efc35b5

Please sign in to comment.