Skip to content

Commit 46cfc42

Browse files
committed
expand datetime search to the first 100 characters of a log line
1 parent 06ae2b9 commit 46cfc42

File tree

3 files changed

+129
-134
lines changed

3 files changed

+129
-134
lines changed

clean.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package logparser
22

33
import (
44
"regexp"
5-
"strings"
65
)
76

87
const (
9-
lookForTimestampLimit = 30
8+
lookForTimestampLimit = 100
109
)
1110

1211
var (
@@ -21,16 +20,8 @@ var (
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-
3425
func containsTimestamp(line string) bool {
3526
if len(line) > lookForTimestampLimit {
3627
line = line[:lookForTimestampLimit]

multiline.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package logparser
22

33
import (
44
"context"
5+
"fmt"
56
"strings"
67
"sync"
78
"time"
@@ -33,7 +34,7 @@ type MultilineCollector struct {
3334
func 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()

0 commit comments

Comments
 (0)