Diff
1diff --git a/config/config.go b/config/config.go
2index 3aa6fa3b633c8642cc35d618f1596103653e0185..b1cb1a472c525c1ac91c618723a04baaea4f93a1 100644
3--- a/config/config.go
4+++ b/config/config.go
5@@ -34,6 +34,8 @@ type Config struct {
6 Raw bool
7 // All after output in record order (causes output to become order)
8 All bool
9+ // How long can a line be?
10+ BufferSize int
11 }
12
13 type rawConfig struct {
14@@ -47,6 +49,7 @@ type rawConfig struct {
15 KeepEmpty bool `long:"keep-empty" short:"k" description:"Keep lines with no field present selected by output or with all excluded"` // nolint:lll
16 Raw bool `long:"raw" short:"r" description:"Output only selected fields values (comma separated) lcut like"` // nolint:lll
17 All bool `long:"all" short:"A" description:"Output all field after the output fields effectivly making it ordered"` // nolint:lll
18+ BufferSize int `long:"buffer-size" short:"B" description:"How long should a line be expected to be?" default:"1048576"`
19 }
20
21 func Parse() (*Config, error) {
22@@ -95,6 +98,9 @@ func Parse() (*Config, error) {
23 if raw.All {
24 cfg.All = true
25 }
26+ if raw.BufferSize != 0 {
27+ cfg.BufferSize = raw.BufferSize
28+ }
29 return &cfg, nil
30 }
31
32diff --git a/parser/parser.go b/parser/parser.go
33index 587ff88df12dc0a37db285e7d0122557bdbce6e1..fd08b23b1b93db1f9d95e7d0b76049d44a79399a 100644
34--- a/parser/parser.go
35+++ b/parser/parser.go
36@@ -26,7 +26,7 @@ func NewParser(cfg *config.Config, input io.Reader, output io.Writer) *Parser {
37
38 // Start starts the parser, reading from the input stream and printing the log output to the output stream line by line
39 func (p *Parser) Start() error {
40- decoder := logfmt.NewDecoder(p.input)
41+ decoder := logfmt.NewDecoderSize(p.input, p.cfg.BufferSize)
42 for decoder.ScanRecord() {
43 record, err := NewRecord(decoder, p.cfg)
44 if err != nil {