mirror of
https://code.dnix.de/da/flokatirc
synced 2026-07-27 08:59:44 +02:00
Beautify logs with xlog
This commit is contained in:
+6
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user