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() defer file.Close()
err = json.NewDecoder(file).Decode(&macros) err = json.NewDecoder(file).Decode(&macros)
if err != nil { 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 return
} }
log.Printf("[macro] Loaded %d macros from %s\n", len(macros), *macropath)
} }
func macro(broker *tg.Broker, update tg.APIMessage) { func macro(broker *tg.Broker, update tg.APIMessage) {
@ -66,11 +67,11 @@ func macro(broker *tg.Broker, update tg.APIMessage) {
func savemacros() { func savemacros() {
file, err := os.Create(*macropath) file, err := os.Create(*macropath)
if err != nil { 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 return
} }
err = json.NewEncoder(file).Encode(macros) err = json.NewEncoder(file).Encode(macros)
if err != nil { 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() { func initmods() {
var enabledmods []string
for name, mod := range mods { for name, mod := range mods {
log.Printf("Initializing %s..", name) log.Printf("Initializing %s..", name)
if mod.OnInit != nil { if mod.OnInit != nil {
mod.OnInit() 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) { func dispatch(broker *tg.Broker, update tg.APIMessage) {

View file

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

View file

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

View file

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