-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
60 lines (45 loc) · 1.33 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/kpfaulkner/gologmine/pkg/logmine"
log "github.com/sirupsen/logrus"
)
func generateMaxDistances(maxDist string) ([]float64, error) {
sp := strings.Split(maxDist, ",")
distances := []float64{}
for _, d := range sp {
f, err := strconv.ParseFloat(d, 64)
if err != nil {
return nil, err
}
distances = append(distances, f)
}
return distances, nil
}
func main() {
fmt.Printf("so it begins...\n")
start := time.Now()
fmt.Printf("start %s\n", start)
maxDist := flag.String("maxdist", "0.01,0.1,0.3,0.9", "Max distances for clustering. Comma separated decimals. eg 0.01,0.05 etc")
maxLevel := flag.Int("maxlevel", 3, "Max level 0-3")
file := flag.String("file", "test.log", "Log file to process")
simplify := flag.Bool("simplify", false, "Simplyify output. Compact sequential WORD, NOSPACE and * outputs to single entry")
flag.Parse()
distances, err := generateMaxDistances(*maxDist)
lm := logmine.NewLogMine(distances)
f, _ := os.Open(*file)
err = lm.ProcessLogsFromReader(f, *maxLevel)
if err != nil {
log.Fatalf("error while processing. %s\n", err.Error())
}
//lm.DisplayFinalOutput(false)
lm.DisplayFinalOutput(*simplify)
end := time.Now()
fmt.Printf("end %s\n", end)
fmt.Printf("took %dms\n", end.Sub(start).Milliseconds())
}