Skip to content

Commit

Permalink
refactor: extra debugging stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jul 29, 2024
1 parent 8ecfb32 commit ffed293
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"

env:
tag_version: v1.6.4
tag_version: v1.6.7
DOCKER_HOST: ssh://root@darklab:22

tasks:
Expand Down
4 changes: 4 additions & 0 deletions app/discorder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func NewClient() *Discorder {

func (d *Discorder) SengMessage(channelID types.DiscordChannelID, content string) error {
_, err := d.dg.ChannelMessageSend(string(channelID), content)
logus.Log.Debug("sending msg to channe",
logus.MsgContent(content),
logus.ChannelID(channelID),
)
logus.Log.CheckWarn(err, "failed sending message in discorder", logus.ChannelID(channelID))
return err
}
Expand Down
16 changes: 16 additions & 0 deletions app/discorder/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package discorder

import (
"testing"

"github.com/darklab8/fl-darkbot/app/settings/logus"
)

func TestLogging(t *testing.T) {

long_test := "long_test_111111111111111111"
short_test := "short"

logus.Log.Warn("send long msg", logus.MsgContent(long_test))
logus.Log.Warn("send shot msg", logus.MsgContent(short_test))
}
6 changes: 5 additions & 1 deletion app/forumer/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ func (v *Forumer) TrySendMsg(channel types.DiscordChannelID, new_post *forum_typ

purple_color := 10181046
embed.Color = purple_color
_, err := dg.ChannelMessageSendComplex(string(channel), &discordgo.MessageSend{Embeds: []*discordgo.MessageEmbed{embed}, Content: string(pingMessage)})
_, err := dg.ChannelMessageSendComplex(string(channel), &discordgo.MessageSend{Embeds: []*discordgo.MessageEmbed{embed}, Content: fmt.Sprintf("mail for %s", string(pingMessage))})
logus.Log.Debug("sent forumer msg",
logus.MsgContent(post_content),
logus.ChannelID(channel),
)
logus.Log.CheckError(err, "failed sending msg")
return nil
})
Expand Down
11 changes: 11 additions & 0 deletions app/settings/logus/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ func ChannelID(value types.DiscordChannelID) typelog.LogType {
return typelog.String("channel_id", string(value))
}

func MsgContent(value string) typelog.LogType {
return typelog.String("content", ShortenedMsg(value))
}

func ShortenedMsg(msg string) string {
if len(msg) > 100 {
return msg[:100]
}
return msg
}

func ChannelIDs(value []types.DiscordChannelID) typelog.LogType {
return typelog.Any("channel_ids", value)
}
Expand Down
3 changes: 2 additions & 1 deletion tf/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module "darkbot" {
configurator_dbname = "production"
consoler_prefix = "."
secrets = local.secrets
tag_version = "v1.6.4"
tag_version = "v1.6.7"
mode = "docker"
environment = "production"
debug = true
}

0 comments on commit ffed293

Please sign in to comment.