Browse Source

Logging added

master
Gregory Rudolph 4 years ago
parent
commit
79f666dd0e
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 4
      chess.go
  2. 1
      main.go

4
chess.go

@ -69,11 +69,12 @@ func chessCommand(m chat1.MsgSummary) { @@ -69,11 +69,12 @@ func chessCommand(m chat1.MsgSummary) {
func showBoard(m chat1.MsgSummary, g *Game) {
defer log.PanicSafe("showBoard")
// create file
log.LogInfo("Creating file for %+v.svg", m.ConvID)
f, err := os.Create(fmt.Sprintf("/home/chessbot/chessbot/games/%+v.svg", m.ConvID))
if err != nil {
log.LogError(fmt.Sprintf("Error in ShowBoard os.Create: %+v\n", err))
}
log.LogInfo("Creating board position (g.Game.Position().String())")
// create board position
fenStr := g.Game.Position().String()
pos := &chess.Position{}
@ -95,6 +96,7 @@ func showBoard(m chat1.MsgSummary, g *Game) { @@ -95,6 +96,7 @@ func showBoard(m chat1.MsgSummary, g *Game) {
}
}
log.LogInfo("Closing file.")
f.Close()
if svgToPNG(fmt.Sprintf("/home/chessbot/chessbot/games/%+v", m.ConvID)) {
k.UploadToConversation(m.ConvID, "", fmt.Sprintf("/home/chessbot/chessbot/games/%+v.png", m.ConvID))

1
main.go

@ -33,7 +33,6 @@ func printChat(m chat1.MsgSummary) { @@ -33,7 +33,6 @@ func printChat(m chat1.MsgSummary) {
chessCommand(m)
return
}
log.LogInfo("%s: %s\n", m.Sender.Username, m.Content.Text.Body)
}
func main() {
fmt.Println("Loading config.")

Loading…
Cancel
Save