Switch user and puppet files to zerolog

This commit is contained in:
Tulir Asokan
2023-03-12 14:25:24 +02:00
parent 15d4cf07f9
commit 46115fafd5
5 changed files with 156 additions and 103 deletions

View File

@@ -78,7 +78,8 @@ func (thread *Thread) Join(user *User) {
if user.IsInPortal(thread.ID) {
return
}
user.log.Debugfln("Joining thread %s@%s", thread.ID, thread.ParentID)
log := user.log.With().Str("thread_id", thread.ID).Str("channel_id", thread.ParentID).Logger()
log.Debug().Msg("Joining thread")
var err error
if user.Session.IsUser {
err = user.Session.ThreadJoinWithLocation(thread.ID, discordgo.ThreadJoinLocationContextMenu)
@@ -86,7 +87,7 @@ func (thread *Thread) Join(user *User) {
err = user.Session.ThreadJoin(thread.ID)
}
if err != nil {
user.log.Errorfln("Error joining thread %s@%s: %v", thread.ID, thread.ParentID, err)
log.Error().Err(err).Msg("Error joining thread")
} else {
user.MarkInPortal(database.UserPortal{
DiscordID: thread.ID,