Commit Diff


commit - 5b0199e0674b051428672a1460ed5109b3cedadf
commit + 3083e3dd1cb493efa7557138726614b1d3758e81
blob - 7d300c15271e3cb09d4575390b9a2fbe754d859f
blob + e3d28a0f2d8b84a79679df36ff2b10219b4b703d
--- m3u8/lex.go
+++ m3u8/lex.go
@@ -4,6 +4,7 @@ import (
 	"bufio"
 	"fmt"
 	"io"
+	"os"
 	"strings"
 	"unicode/utf8"
 )
@@ -73,6 +74,9 @@ type lexer struct {
 	pos   int
 	width int
 	items chan item
+
+	// if enabled, emitted items are printed to standard error.
+	debug bool
 }
 
 type stateFn func(*lexer) stateFn
@@ -113,7 +117,9 @@ func (l *lexer) run() {
 
 func (l *lexer) emit(t itemType) {
 	l.items <- item{t, l.input[l.start:l.pos]}
-	// fmt.Println(item{t, l.input[l.start:l.pos]})
+	if l.debug {
+		fmt.Fprintln(os.Stderr, item{t, l.input[l.start:l.pos]})
+	}
 	l.start = l.pos
 }