Skip to content

Commit

Permalink
configurable multilineCollectorTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
def committed Nov 29, 2024
1 parent 9f9cca5 commit 8c2b842
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions cmd/logparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"errors"
"flag"
"fmt"
"github.com/coroot/logparser"
"io"
"os"
"sort"
"strconv"
"strings"
"time"

"github.com/coroot/logparser"
)

func main() {
Expand All @@ -22,7 +23,7 @@ func main() {

reader := bufio.NewReader(os.Stdin)
ch := make(chan logparser.LogEntry)
parser := logparser.NewParser(ch, nil, nil)
parser := logparser.NewParser(ch, nil, nil, time.Second)
t := time.Now()
for {
line, err := reader.ReadString('\n')
Expand Down
3 changes: 1 addition & 2 deletions multiline.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
)

var (
multilineCollectorTimeout = time.Millisecond * 100
multilineCollectorLimit = 64 * 1024
multilineCollectorLimit = 64 * 1024
)

type Message struct {
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Parser struct {

type OnMsgCallbackF func(ts time.Time, level Level, patternHash string, msg string)

func NewParser(ch <-chan LogEntry, decoder Decoder, onMsgCallback OnMsgCallbackF) *Parser {
func NewParser(ch <-chan LogEntry, decoder Decoder, onMsgCallback OnMsgCallbackF, multilineCollectorTimeout time.Duration) *Parser {
p := &Parser{
decoder: decoder,
patterns: map[patternKey]*patternStat{},
Expand Down

0 comments on commit 8c2b842

Please sign in to comment.