File tree Expand file tree Collapse file tree 3 files changed +129
-134
lines changed
Expand file tree Collapse file tree 3 files changed +129
-134
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,10 @@ package logparser
22
33import (
44 "regexp"
5- "strings"
65)
76
87const (
9- lookForTimestampLimit = 30
8+ lookForTimestampLimit = 100
109)
1110
1211var (
2120 regexp .MustCompile (`\d{2}/\d{2}/\d{4}` ),
2221 regexp .MustCompile (`\d{2}\.\d{2}\.\d{4}` ),
2322 }
24- extraSpaces = regexp .MustCompile (`\s+` )
2523)
2624
27- func clean (line string ) string {
28- for _ , r := range timestampRegexes {
29- line = r .ReplaceAllString (line , "" )
30- }
31- return strings .TrimSpace (extraSpaces .ReplaceAllString (line , " " ))
32- }
33-
3425func containsTimestamp (line string ) bool {
3526 if len (line ) > lookForTimestampLimit {
3627 line = line [:lookForTimestampLimit ]
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package logparser
22
33import (
44 "context"
5+ "fmt"
56 "strings"
67 "sync"
78 "time"
@@ -33,7 +34,7 @@ type MultilineCollector struct {
3334func NewMultilineCollector (ctx context.Context , timeout time.Duration ) * MultilineCollector {
3435 m := & MultilineCollector {
3536 timeout : timeout ,
36- Messages : make (chan Message , 1 ),
37+ Messages : make (chan Message , 100 ),
3738 }
3839 go m .dispatch (ctx )
3940 return m
@@ -88,6 +89,7 @@ func (m *MultilineCollector) add(entry LogEntry) {
8889 m .level = entry .Level
8990 }
9091 m .isFirstLineContainsTimestamp = containsTimestamp (entry .Content )
92+ fmt .Println (m .isFirstLineContainsTimestamp , entry .Content )
9193 }
9294 m .appendLine (entry .Content )
9395 m .lastReceiveTime = time .Now ()
You can’t perform that action at this time.
0 commit comments