Преглед на файлове

Change all fmt.Println to log.Println

Toni Fadjukoff преди 6 години
родител
ревизия
7f454cb777
променени са 1 файла, в които са добавени 11 реда и са изтрити 11 реда
  1. 11 11
      bot.go

+ 11 - 11
bot.go Целия файл

@@ -90,7 +90,7 @@ func (app *App) AddSong(updateTitle, updateSection, author, song string) (bool,
90 90
 
91 91
 			if false {
92 92
 				// Stub
93
-				fmt.Println("Pretend to update wiki text to ", updateTitle, section.index, changedWikiText,
93
+				log.Println("Pretend to update wiki text to ", updateTitle, section.index, changedWikiText,
94 94
 					fmt.Sprintf("Added %s song for %s", updateSection, author))
95 95
 				return true, nil
96 96
 			}
@@ -117,7 +117,7 @@ func (app *App) SubmitSongs() {
117 117
 	for _, entry := range entries {
118 118
 		song := songWikiText(entry.spotifyURL, entry.artist, entry.title)
119 119
 
120
-		fmt.Println("Time has passed for " + song)
120
+		log.Println("Time has passed for " + song)
121 121
 
122 122
 		success, err := app.AddSong(entry.article, entry.section, entry.username, song)
123 123
 		if err != nil {
@@ -126,7 +126,7 @@ func (app *App) SubmitSongs() {
126 126
 		if success {
127 127
 			err = app.SongSynced(entry.userId, entry.roundId)
128 128
 			if err != nil {
129
-				fmt.Println("Error received:", err)
129
+				log.Println("Error received:", err)
130 130
 			}
131 131
 		}
132 132
 	}
@@ -147,7 +147,7 @@ func parseScore(line string) string {
147 147
 	if score == "" {
148 148
 		return score
149 149
 	}
150
-	rating, _ := regexp.Compile("^\\{\\{Rating\\|\\d([.,]\\d)\\|5\\}\\}?$")
150
+	rating, _ := regexp.Compile("^\\{\\{Rating\\|\\d([.,]\\d)?\\|5\\}\\}$")
151 151
 	if rating.MatchString(score) {
152 152
 		score = strings.Replace(score, "{{Rating|", "", 1)
153 153
 		score = strings.Replace(score, "|5}}", "", 1)
@@ -176,7 +176,7 @@ func parseScore(line string) string {
176 176
 	if thirdQuarterScore.MatchString(score) {
177 177
 		return fmt.Sprintf("%c.75", score[0])
178 178
 	}
179
-	fmt.Printf("Could not match '%s'\n", score)
179
+	log.Printf("Could not match '%s'\n", score)
180 180
 	return ""
181 181
 }
182 182
 
@@ -215,7 +215,7 @@ func appendAverages(wikiText string) string {
215 215
 			newLine := "| " + AVERAGE_MARK + " " + expression
216 216
 			changedLines = append(changedLines, newLine)
217 217
 			if newLine != line {
218
-				fmt.Printf("Difference for %s\n%s\n%s\n", currentAuthor, newLine, line)
218
+				log.Printf("Difference for %s\n%s\n%s\n", currentAuthor, newLine, line)
219 219
 			}
220 220
 
221 221
 		} else {
@@ -256,7 +256,7 @@ func findPlaylist(wikiText string) (string, []string) {
256 256
 			}
257 257
 		}
258 258
 	}
259
-	fmt.Printf("Found playlist %s and tracks %s\n", playlistId, tracks)
259
+	log.Printf("Found playlist %s and tracks %s\n", playlistId, tracks)
260 260
 
261 261
 	return playlistId, tracks
262 262
 }
@@ -288,7 +288,7 @@ func (app *App) AutomateSection(title string) error {
288 288
 			if weekNumber > currentWeek {
289 289
 				break
290 290
 			}
291
-			fmt.Println("Checking section", section.title)
291
+			log.Println("Checking section", section.title)
292 292
 
293 293
 			wikiText, err := wiki.GetWikiPageSectionText(title, section.index)
294 294
 			if err != nil {
@@ -347,14 +347,14 @@ func (app *App) AutomateSection(title string) error {
347 347
 func (app *App) AutomateSectionTask() {
348 348
 	panels, err := app.db.FindAllPanels()
349 349
 	if err != nil {
350
-		fmt.Println("Error while checking db for panels:", err)
350
+		log.Println("Error while checking db for panels:", err)
351 351
 		return
352 352
 	}
353 353
 	for _, panel := range panels {
354
-		fmt.Println("Checking panel", panel)
354
+		log.Println("Checking panel", panel)
355 355
 		err := app.AutomateSection(panel)
356 356
 		if err != nil {
357
-			fmt.Println("Error while processing panel:", err)
357
+			log.Println("Error while processing panel:", err)
358 358
 		}
359 359
 	}
360 360