refactor: log parser names (again :))

This commit is contained in:
Inanc Gumus
2019-08-06 03:32:24 +03:00
parent 69094da997
commit 9c57aad7d9
5 changed files with 47 additions and 61 deletions

View File

@@ -19,17 +19,19 @@ const (
dashLength = 58
)
func textWriter(w io.Writer, results []result) error {
fmt.Fprintf(w, header, "DOMAINS", "PAGES", "VISITS", "UNIQUES")
fmt.Fprintln(w, strings.Repeat("-", dashLength))
func textWriter(w io.Writer) outputFunc {
return func(results []result) error {
fmt.Fprintf(w, header, "DOMAINS", "PAGES", "VISITS", "UNIQUES")
fmt.Fprintln(w, strings.Repeat("-", dashLength))
var total result
for _, r := range results {
total = total.add(r)
fmt.Fprintf(w, line, r.domain, r.page, r.visits, r.uniques)
var total result
for _, r := range results {
total = total.add(r)
fmt.Fprintf(w, line, r.domain, r.page, r.visits, r.uniques)
}
fmt.Fprintf(w, footer, "", total.visits, total.uniques)
return nil
}
fmt.Fprintf(w, footer, "", total.visits, total.uniques)
return nil
}