Beautify logs with xlog

This commit is contained in:
Andreas Neue
2016-03-12 13:09:25 +01:00
parent 13379b29ea
commit 1dea72f6c7
11 changed files with 60 additions and 48 deletions
+6 -5
View File
@@ -10,12 +10,13 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
"time"
"code.dnix.de/an/xlog"
"github.com/sorcix/irc"
)
@@ -71,8 +72,8 @@ type WeatherObject struct {
func init() {
MsgHandlers["weather"] = weatherHandleMessage
log.Println("Initializing weather module")
go weatherConfig()
xlog.Info("Weather module initialized")
}
func weatherConfig() {
@@ -105,19 +106,19 @@ func getWeather(query string) {
q := owmQueryURLPrefix + query + owmQueryURLSuffix + owmQueryAPIKey
r, err := http.Get(q)
if err != nil {
log.Println(err)
xlog.Error(err.Error())
SayCh <- fmt.Sprintf("*\n%s", weatherPrefix+err.Error())
} else {
re, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Println(err)
xlog.Error(err.Error())
SayCh <- fmt.Sprintf("*\n%s", weatherPrefix+err.Error())
} else {
defer r.Body.Close()
var wo WeatherObject
err := json.Unmarshal(re, &wo)
if err != nil {
log.Println(err)
xlog.Error(err.Error())
SayCh <- fmt.Sprintf("*\n%s", weatherPrefix+err.Error())
} else {
var description string