Browse Source

moved logging to main

master
David Haukeness 5 years ago
parent
commit
755559d0bb
No known key found for this signature in database
GPG Key ID: 54F2372DDB7F9462
  1. 13
      main.go
  2. 10
      utils.go

13
main.go

@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
"log"
"os"
"github.com/teris-io/shortid"
"samhofi.us/x/keybase"
"samhofi.us/x/keybase/types/chat1"
"samhofi.us/x/keybase/types/stellar1"
@ -29,13 +30,23 @@ type botConfig struct { @@ -29,13 +30,23 @@ type botConfig struct {
KVStoreTeam string `env:"BOT_KVSTORE_TEAM" envDefault:""`
}
// Debug provides printing only when --debug flag is set or BOT_DEBUG env var is set
// debug provides printing only when --debug flag is set or BOT_DEBUG env var is set
func (b *bot) debug(s string, a ...interface{}) {
if b.config.Debug {
b.log(s, a...)
}
}
// logError generates an error id and returns it for error reporting, and writes the error to logging locations
func (b *bot) logError(err error) string {
// generate the error id
eid := shortid.MustGenerate()
// send the error to the log
b.log("`%s` - %s", eid, err)
// then return the error id for use
return eid
}
// logToChat will send this message to the keybase chat configured in b.config.LogConvIDStr
func (b *bot) log(s string, a ...interface{}) {
// if the ConvIdStr isn't blank try to log to chat

10
utils.go

@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"github.com/teris-io/shortid"
"samhofi.us/x/keybase/types/chat1"
)
@ -29,12 +28,3 @@ func getFeedbackExtendedDescription(bc botConfig) *chat1.UserBotExtendedDescript @@ -29,12 +28,3 @@ func getFeedbackExtendedDescription(bc botConfig) *chat1.UserBotExtendedDescript
MobileBody: "Please note: Your feedback will be public!",
}
}
func (b *bot) logError(err error) string {
// generate the error id
eid := shortid.MustGenerate()
// send the error to the log
b.log("`%s` - %s", eid, err)
// then return the error id for use
return eid
}

Loading…
Cancel
Save