More logging for the log god

This commit is contained in:
Hamcha 2017-03-15 21:20:07 +01:00
parent 257802eb8a
commit a9a5b8641b
5 changed files with 16 additions and 4 deletions

View File

@ -29,9 +29,10 @@ func initmacro() {
defer file.Close()
err = json.NewDecoder(file).Decode(&macros)
if err != nil {
log.Println("WARN: Could not load macros (malformed or unreadable file): " + err.Error())
log.Println("[macro] WARN: Could not load macros (malformed or unreadable file): " + err.Error())
return
}
log.Printf("[macro] Loaded %d macros from %s\n", len(macros), *macropath)
}
func macro(broker *tg.Broker, update tg.APIMessage) {
@ -66,11 +67,11 @@ func macro(broker *tg.Broker, update tg.APIMessage) {
func savemacros() {
file, err := os.Create(*macropath)
if err != nil {
log.Println("WARN: Could not open macro db: " + err.Error())
log.Println("[macro] WARN: Could not open macro db: " + err.Error())
return
}
err = json.NewEncoder(file).Encode(macros)
if err != nil {
log.Println("WARN: Could not save macros into file: " + err.Error())
log.Println("[macro] WARN: Could not save macros into file: " + err.Error())
}
}

View File

@ -42,12 +42,18 @@ var mods = map[string]Mod{
}
func initmods() {
var enabledmods []string
for name, mod := range mods {
log.Printf("Initializing %s..", name)
if mod.OnInit != nil {
mod.OnInit()
}
enabledmods = append(enabledmods, name)
}
log.Println("===============================")
log.Println("All mods have been initialized!")
log.Println("===============================")
log.Println("Active modules: " + strings.Join(enabledmods, ", "))
}
func dispatch(broker *tg.Broker, update tg.APIMessage) {

View File

@ -33,6 +33,8 @@ func initmeme() {
memeFontData = draw2d.FontData{"impact", draw2d.FontFamilySans, 0}
draw2d.RegisterFont(memeFontData, font)
log.Println("[meme] Loaded!")
}
func memegen(broker *tg.Broker, update tg.APIMessage) {

View File

@ -40,6 +40,8 @@ func initsnapchat() {
snapFontData = draw2d.FontData{"sourcesans", draw2d.FontFamilySans, draw2d.FontStyleBold}
draw2d.RegisterFont(snapFontData, font)
log.Println("[snapchat] Loaded!")
}
func snapchat(broker *tg.Broker, update tg.APIMessage) {

View File

@ -37,6 +37,8 @@ func initunsplash() {
quoteFontData = draw2d.FontData{"gillmt", draw2d.FontFamilySans, draw2d.FontStyleBold}
draw2d.RegisterFont(quoteFontData, font)
log.Println("[unsplash] Loaded!")
}
func unsplash(broker *tg.Broker, update tg.APIMessage) {
@ -132,7 +134,6 @@ func unsplash(broker *tg.Broker, update tg.APIMessage) {
// Still too big? Decrease font size again
iter := 0
for width*1.2 > iwidth && iter < 10 {
log.Println("Warning, resizing!")
scale *= (0.9 - 0.05*float64(iter))
gc.SetFontSize(scale)
left, top, right, bottom = gc.GetStringBounds(texts[longid])