Add a bunch of new logging

This commit is contained in:
Tulir Asokan
2019-01-21 23:55:16 +02:00
parent 79bd35964f
commit 9e170f3d04
9 changed files with 53 additions and 30 deletions

View File

@ -92,20 +92,18 @@ func (puppet *Puppet) Scan(row Scannable) *Puppet {
return puppet
}
func (puppet *Puppet) Insert() error {
func (puppet *Puppet) Insert() {
_, err := puppet.db.Exec("INSERT INTO puppet VALUES (?, ?, ?, ?)",
puppet.JID, puppet.Avatar, puppet.Displayname, puppet.NameQuality)
if err != nil {
puppet.log.Warnfln("Failed to insert %s: %v", puppet.JID, err)
}
return err
}
func (puppet *Puppet) Update() error {
func (puppet *Puppet) Update() {
_, err := puppet.db.Exec("UPDATE puppet SET displayname=?, name_quality=?, avatar=? WHERE jid=?",
puppet.Displayname, puppet.NameQuality, puppet.Avatar, puppet.JID)
if err != nil {
puppet.log.Warnfln("Failed to update %s->%s: %v", puppet.JID, err)
}
return err
}