diff --git a/makefile b/makefile index f649865..cb77f52 100644 --- a/makefile +++ b/makefile @@ -42,7 +42,7 @@ snake2camel: }' $(file) .PHONY: bench -bench: rfc5424/*_test.go rfc5424/machine.go +bench: rfc5424/*_test.go rfc5424/machine.go octetcounting/performance_test.go go test -bench=. -benchmem -benchtime=5s ./... .PHONY: tests diff --git a/nontransparent/parser.go b/nontransparent/parser.go index 4eae95d..c587202 100644 --- a/nontransparent/parser.go +++ b/nontransparent/parser.go @@ -218,6 +218,9 @@ func NewParser(options ...syslog.ParserOption) syslog.Parser { return m } +// WithMaxMessageLength does nothing for this parser +func (m *machine) WithMaxMessageLength(length int) {} + // HasBestEffort tells whether the receiving parser has best effort mode on or off. func (m *machine) HasBestEffort() bool { return m.bestEffort diff --git a/octetcounting/parser.go b/octetcounting/parser.go index c1f0c88..a79c668 100644 --- a/octetcounting/parser.go +++ b/octetcounting/parser.go @@ -12,19 +12,21 @@ import ( // // Use NewParser function to instantiate one. type parser struct { - msglen int64 - s Scanner - internal syslog.Machine - last Token - stepback bool // Wheter to retrieve the last token or not - bestEffort bool // Best effort mode flag - emit syslog.ParserListener + msglen int64 + maxMessageLength int + s Scanner + internal syslog.Machine + last Token + stepback bool // Wheter to retrieve the last token or not + bestEffort bool // Best effort mode flag + emit syslog.ParserListener } // NewParser returns a syslog.Parser suitable to parse syslog messages sent with transparent - ie. octet counting (RFC 5425) - framing. func NewParser(opts ...syslog.ParserOption) syslog.Parser { p := &parser{ - emit: func(*syslog.Result) { /* noop */ }, + emit: func(*syslog.Result) { /* noop */ }, + maxMessageLength: 8192, // size as per RFC5425#section-4.3.1 } for _, opt := range opts { @@ -41,6 +43,10 @@ func NewParser(opts ...syslog.ParserOption) syslog.Parser { return p } +func (p *parser) WithMaxMessageLength(length int) { + p.maxMessageLength = length +} + // HasBestEffort tells whether the receiving parser has best effort mode on or off. func (p *parser) HasBestEffort() bool { return p.bestEffort @@ -64,7 +70,7 @@ func (p *parser) WithListener(f syslog.ParserListener) { // // It stops parsing when an error regarding RFC 5425 is found. func (p *parser) Parse(r io.Reader) { - p.s = *NewScanner(r) + p.s = *NewScanner(r, p.maxMessageLength) p.run() } diff --git a/octetcounting/parser_test.go b/octetcounting/parser_test.go index 764cd5d..53521b6 100644 --- a/octetcounting/parser_test.go +++ b/octetcounting/parser_test.go @@ -12,10 +12,11 @@ import ( ) type testCase struct { - descr string - input string - results []syslog.Result - pResults []syslog.Result + descr string + input string + results []syslog.Result + bestEffortResults []syslog.Result + maxMessageLength int } var testCases []testCase @@ -31,20 +32,20 @@ func getParsingError(col int) error { func getTestCases() []testCase { return []testCase{ { - "empty", - "", - []syslog.Result{ + descr: "empty", + input: "", + results: []syslog.Result{ {Error: fmt.Errorf("found %s, expecting a %s", EOF, MSGLEN)}, }, - []syslog.Result{ + bestEffortResults: []syslog.Result{ {Error: fmt.Errorf("found %s, expecting a %s", EOF, MSGLEN)}, }, }, { - "1st ok/2nd mf", // mf means malformed syslog message - "16 <1>1 - - - - - -17 <2>12 A B C D E -", + descr: "1st ok/2nd mf", // mf means malformed syslog message + input: "16 <1>1 - - - - - -17 <2>12 A B C D E -", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), }, @@ -53,7 +54,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), }, @@ -64,10 +65,10 @@ func getTestCases() []testCase { }, }, { - "1st ok/2nd ko", // ko means wrong token - "16 <1>1 - - - - - -xaaa", + descr: "1st ok/2nd ko", // ko means wrong token + input: "16 <1>1 - - - - - -xaaa", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), }, @@ -76,7 +77,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), }, @@ -86,16 +87,16 @@ func getTestCases() []testCase { }, }, { - "1st ml/2nd ko", - "16 <1>1 A B C D E -xaaa", + descr: "1st ml/2nd ko", + input: "16 <1>1 A B C D E -xaaa", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Error: getTimestampError(5), }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), Error: getTimestampError(5), @@ -106,10 +107,10 @@ func getTestCases() []testCase { }, }, { - "1st ok//utf8", - "23 <1>1 - - - - - - hellø", // msglen MUST be the octet count + descr: "1st ok//utf8", + input: "23 <1>1 - - - - - - hellø", // msglen MUST be the octet count //results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(1). @@ -118,7 +119,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(1). @@ -128,16 +129,16 @@ func getTestCases() []testCase { }, }, { - "1st ko//incomplete SYSLOGMSG", - "16 <1>1", + descr: "1st ko//incomplete SYSLOGMSG", + input: "16 <1>1", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Error: fmt.Errorf(`found %s after "%s", expecting a %s containing %d octets`, EOF, "<1>1", SYSLOGMSG, 16), }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), Error: getParsingError(4), @@ -146,42 +147,42 @@ func getTestCases() []testCase { }, }, { - "1st ko//missing WS found ILLEGAL", - "16<1>1", + descr: "1st ko//missing WS found ILLEGAL", + input: "16<1>1", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Error: fmt.Errorf("found %s, expecting a %s", Token{ILLEGAL, []byte("<")}, WS), }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Error: fmt.Errorf("found %s, expecting a %s", Token{ILLEGAL, []byte("<")}, WS), }, }, }, { - "1st ko//missing WS found EOF", - "1", + descr: "1st ko//missing WS found EOF", + input: "1", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Error: fmt.Errorf("found %s, expecting a %s", EOF, WS), }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Error: fmt.Errorf("found %s, expecting a %s", EOF, WS), }, }, }, { - "1st ok/2nd ok/3rd ok", - "48 <1>1 2003-10-11T22:14:15.003Z host.local - - - -25 <3>1 - host.local - - - -38 <2>1 - host.local su - - - κόσμε", + descr: "1st ok/2nd ok/3rd ok", + input: "48 <1>1 2003-10-11T22:14:15.003Z host.local - - - -25 <3>1 - host.local - - - -38 <2>1 - host.local su - - - κόσμε", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(1). @@ -205,7 +206,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(1). @@ -230,10 +231,10 @@ func getTestCases() []testCase { }, }, { - "1st ok/2nd mf/3rd ok", // mf means malformed syslog message - "16 <1>1 - - - - - -17 <2>12 A B C D E -16 <1>1 - - - - - -", + descr: "1st ok/2nd mf/3rd ok", // mf means malformed syslog message + input: "16 <1>1 - - - - - -17 <2>12 A B C D E -16 <1>1 - - - - - -", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), }, @@ -242,7 +243,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(1), }, @@ -256,8 +257,8 @@ func getTestCases() []testCase { }, }, { - "1st ok//max", - fmt.Sprintf( + descr: "1st ok//max", + input: fmt.Sprintf( "8192 <%d>%d %s %s %s %s %s - %s", syslogtesting.MaxPriority, syslogtesting.MaxVersion, @@ -269,7 +270,7 @@ func getTestCases() []testCase { string(syslogtesting.MaxMessage), ), // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -283,7 +284,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -298,8 +299,51 @@ func getTestCases() []testCase { }, }, { - "1st ok/2nd ok//max/max", - fmt.Sprintf( + descr: "1st ok//longer-max", + input: fmt.Sprintf( + "65529 <%d>%d %s %s %s %s %s - %s", + syslogtesting.MaxPriority, + syslogtesting.MaxVersion, + syslogtesting.MaxRFC3339MicroTimestamp, + string(syslogtesting.MaxHostname), + string(syslogtesting.MaxAppname), + string(syslogtesting.MaxProcID), + string(syslogtesting.MaxMsgID), + string(syslogtesting.LongerMaxMessage), + ), + // results w/o best effort + results: []syslog.Result{ + { + Message: (&rfc5424.SyslogMessage{}). + SetPriority(syslogtesting.MaxPriority). + SetVersion(syslogtesting.MaxVersion). + SetTimestamp(syslogtesting.MaxRFC3339MicroTimestamp). + SetHostname(string(syslogtesting.MaxHostname)). + SetAppname(string(syslogtesting.MaxAppname)). + SetProcID(string(syslogtesting.MaxProcID)). + SetMsgID(string(syslogtesting.MaxMsgID)). + SetMessage(string(syslogtesting.LongerMaxMessage)), + }, + }, + // results with best effort + bestEffortResults: []syslog.Result{ + { + Message: (&rfc5424.SyslogMessage{}). + SetPriority(syslogtesting.MaxPriority). + SetVersion(syslogtesting.MaxVersion). + SetTimestamp(syslogtesting.MaxRFC3339MicroTimestamp). + SetHostname(string(syslogtesting.MaxHostname)). + SetAppname(string(syslogtesting.MaxAppname)). + SetProcID(string(syslogtesting.MaxProcID)). + SetMsgID(string(syslogtesting.MaxMsgID)). + SetMessage(string(syslogtesting.LongerMaxMessage)), + }, + }, + maxMessageLength: 65529, + }, + { + descr: "1st ok/2nd ok//max/max", + input: fmt.Sprintf( "8192 <%d>%d %s %s %s %s %s - %s8192 <%d>%d %s %s %s %s %s - %s", syslogtesting.MaxPriority, syslogtesting.MaxVersion, @@ -319,7 +363,7 @@ func getTestCases() []testCase { string(syslogtesting.MaxMessage), ), // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -344,7 +388,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -370,8 +414,81 @@ func getTestCases() []testCase { }, }, { - "1st ok/2nd ok/3rd ok//max/no/max", - fmt.Sprintf( + descr: "1st ok/2nd ok//longer-max/longer-max", + input: fmt.Sprintf( + "65529 <%d>%d %s %s %s %s %s - %s65529 <%d>%d %s %s %s %s %s - %s", + syslogtesting.MaxPriority, + syslogtesting.MaxVersion, + syslogtesting.MaxRFC3339MicroTimestamp, + string(syslogtesting.MaxHostname), + string(syslogtesting.MaxAppname), + string(syslogtesting.MaxProcID), + string(syslogtesting.MaxMsgID), + string(syslogtesting.LongerMaxMessage), + syslogtesting.MaxPriority, + syslogtesting.MaxVersion, + syslogtesting.MaxRFC3339MicroTimestamp, + string(syslogtesting.MaxHostname), + string(syslogtesting.MaxAppname), + string(syslogtesting.MaxProcID), + string(syslogtesting.MaxMsgID), + string(syslogtesting.LongerMaxMessage), + ), + // results w/o best effort + results: []syslog.Result{ + { + Message: (&rfc5424.SyslogMessage{}). + SetPriority(syslogtesting.MaxPriority). + SetVersion(syslogtesting.MaxVersion). + SetTimestamp(syslogtesting.MaxRFC3339MicroTimestamp). + SetHostname(string(syslogtesting.MaxHostname)). + SetAppname(string(syslogtesting.MaxAppname)). + SetProcID(string(syslogtesting.MaxProcID)). + SetMsgID(string(syslogtesting.MaxMsgID)). + SetMessage(string(syslogtesting.LongerMaxMessage)), + }, + { + Message: (&rfc5424.SyslogMessage{}). + SetPriority(syslogtesting.MaxPriority). + SetVersion(syslogtesting.MaxVersion). + SetTimestamp(syslogtesting.MaxRFC3339MicroTimestamp). + SetHostname(string(syslogtesting.MaxHostname)). + SetAppname(string(syslogtesting.MaxAppname)). + SetProcID(string(syslogtesting.MaxProcID)). + SetMsgID(string(syslogtesting.MaxMsgID)). + SetMessage(string(syslogtesting.LongerMaxMessage)), + }, + }, + // results with best effort + bestEffortResults: []syslog.Result{ + { + Message: (&rfc5424.SyslogMessage{}). + SetPriority(syslogtesting.MaxPriority). + SetVersion(syslogtesting.MaxVersion). + SetTimestamp(syslogtesting.MaxRFC3339MicroTimestamp). + SetHostname(string(syslogtesting.MaxHostname)). + SetAppname(string(syslogtesting.MaxAppname)). + SetProcID(string(syslogtesting.MaxProcID)). + SetMsgID(string(syslogtesting.MaxMsgID)). + SetMessage(string(syslogtesting.LongerMaxMessage)), + }, + { + Message: (&rfc5424.SyslogMessage{}). + SetPriority(syslogtesting.MaxPriority). + SetVersion(syslogtesting.MaxVersion). + SetTimestamp(syslogtesting.MaxRFC3339MicroTimestamp). + SetHostname(string(syslogtesting.MaxHostname)). + SetAppname(string(syslogtesting.MaxAppname)). + SetProcID(string(syslogtesting.MaxProcID)). + SetMsgID(string(syslogtesting.MaxMsgID)). + SetMessage(string(syslogtesting.LongerMaxMessage)), + }, + }, + maxMessageLength: 65529, + }, + { + descr: "1st ok/2nd ok/3rd ok//max/no/max", + input: fmt.Sprintf( "8192 <%d>%d %s %s %s %s %s - %s16 <1>1 - - - - - -8192 <%d>%d %s %s %s %s %s - %s", syslogtesting.MaxPriority, syslogtesting.MaxVersion, @@ -391,7 +508,7 @@ func getTestCases() []testCase { string(syslogtesting.MaxMessage), ), // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -419,7 +536,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -448,8 +565,8 @@ func getTestCases() []testCase { }, }, { - "1st ml//maxlen gt 8192", // maxlength greather than the buffer size - fmt.Sprintf( + descr: "1st ml//maxlen gt 8192", // maxlength greather than the buffer size + input: fmt.Sprintf( "8193 <%d>%d %s %s %s %s %s - %s", syslogtesting.MaxPriority, syslogtesting.MaxVersion, @@ -461,7 +578,7 @@ func getTestCases() []testCase { string(syslogtesting.MaxMessage), ), // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Error: fmt.Errorf( "found %s after \"%s\", expecting a %s containing %d octets", @@ -482,7 +599,7 @@ func getTestCases() []testCase { }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}). SetPriority(syslogtesting.MaxPriority). @@ -513,16 +630,16 @@ func getTestCases() []testCase { }, }, { - "1st uf/2nd ok//incomplete SYSLOGMSG/notdetectable", - "16 <1>217 <11>1 - - - - - -", + descr: "1st uf/2nd ok//incomplete SYSLOGMSG/notdetectable", + input: "16 <1>217 <11>1 - - - - - -", // results w/o best effort - []syslog.Result{ + results: []syslog.Result{ { Error: getTimestampError(7), }, }, // results with best effort - []syslog.Result{ + bestEffortResults: []syslog.Result{ { Message: (&rfc5424.SyslogMessage{}).SetPriority(1).SetVersion(217), Error: getTimestampError(7), @@ -540,16 +657,20 @@ func init() { } func TestParse(t *testing.T) { - for _, tc := range testCases { - tc := tc - + for i := range testCases { + tc := testCases[i] // tests could be running in parallel, needs to be scoped. + if tc.maxMessageLength == 0 { + tc.maxMessageLength = 8192 + } t.Run(fmt.Sprintf("strict/%s", tc.descr), func(t *testing.T) { t.Parallel() res := []syslog.Result{} - strictParser := NewParser(syslog.WithListener(func(r *syslog.Result) { - res = append(res, *r) - })) + strictParser := NewParser( + syslog.WithListener(func(r *syslog.Result) { + res = append(res, *r) + }), + syslog.WithMaxMessageLength(tc.maxMessageLength)) strictParser.Parse(strings.NewReader(tc.input)) assert.Equal(t, tc.results, res) @@ -558,12 +679,16 @@ func TestParse(t *testing.T) { t.Parallel() res := []syslog.Result{} - effortParser := NewParser(syslog.WithBestEffort(), syslog.WithListener(func(r *syslog.Result) { - res = append(res, *r) - })) + effortParser := NewParser( + syslog.WithBestEffort(), + syslog.WithListener(func(r *syslog.Result) { + res = append(res, *r) + }), + syslog.WithMaxMessageLength(tc.maxMessageLength), + ) effortParser.Parse(strings.NewReader(tc.input)) - assert.Equal(t, tc.pResults, res) + assert.Equal(t, tc.bestEffortResults, res) }) } } diff --git a/octetcounting/performance_test.go b/octetcounting/performance_test.go new file mode 100644 index 0000000..9ba5865 --- /dev/null +++ b/octetcounting/performance_test.go @@ -0,0 +1,73 @@ +package octetcounting + +import ( + "bytes" + "fmt" + "testing" + + "github.com/influxdata/go-syslog/v3" + syslogtesting "github.com/influxdata/go-syslog/v3/testing" +) + +// This is here to avoid compiler optimizations that +// could remove the actual call we are benchmarking +// during benchmarks +var benchParseResult syslog.Message + +type benchCase struct { + input []byte + label string + maxLength int +} + +var benchCases = []benchCase{ + { + label: "Small Message Size", + input: []byte("48 <1>1 2003-10-11T22:14:15.003Z host.local - - - -25 <3>1 - host.local - - - -38 <2>1 - host.local su - - - κόσμε"), + }, + { + label: "Default Max Message Size", + input: []byte(fmt.Sprintf( + "8192 <%d>%d %s %s %s %s %s - %s", + syslogtesting.MaxPriority, + syslogtesting.MaxVersion, + syslogtesting.MaxRFC3339MicroTimestamp, + string(syslogtesting.MaxHostname), + string(syslogtesting.MaxAppname), + string(syslogtesting.MaxProcID), + string(syslogtesting.MaxMsgID), + string(syslogtesting.MaxMessage), + )), + }, + { + label: "UDP Max Message Size", + input: []byte(fmt.Sprintf( + "65529 <%d>%d %s %s %s %s %s - %s", + syslogtesting.MaxPriority, + syslogtesting.MaxVersion, + syslogtesting.MaxRFC3339MicroTimestamp, + string(syslogtesting.MaxHostname), + string(syslogtesting.MaxAppname), + string(syslogtesting.MaxProcID), + string(syslogtesting.MaxMsgID), + string(syslogtesting.LongerMaxMessage), + )), + maxLength: 65529, + }, +} + +func BenchmarkParse(b *testing.B) { + for _, tc := range benchCases { + tc := tc + if tc.maxLength == 0 { + tc.maxLength = 8192 + } + m := NewParser(syslog.WithBestEffort()) + b.Run(syslogtesting.RightPad(tc.label, 50), func(b *testing.B) { + for i := 0; i < b.N; i++ { + reader := bytes.NewReader(tc.input) + m.Parse(reader) + } + }) + } +} diff --git a/octetcounting/scanner.go b/octetcounting/scanner.go index 015295f..cb1fae0 100644 --- a/octetcounting/scanner.go +++ b/octetcounting/scanner.go @@ -7,9 +7,6 @@ import ( "strconv" ) -// size as per RFC5425#section-4.3.1 -var size = 8192 - // eof represents a marker byte for the end of the reader var eof = byte(0) @@ -37,9 +34,9 @@ type Scanner struct { } // NewScanner returns a pointer to a new instance of Scanner. -func NewScanner(r io.Reader) *Scanner { +func NewScanner(r io.Reader, maxLength int) *Scanner { return &Scanner{ - r: bufio.NewReaderSize(r, size+5), // "8192 " has length 5 + r: bufio.NewReaderSize(r, maxLength+20), // max uint64 is 19 characters + a space } } diff --git a/options.go b/options.go index 551a0ed..b03ac1f 100644 --- a/options.go +++ b/options.go @@ -17,3 +17,11 @@ func WithBestEffort() ParserOption { return p } } + +// WithMaxMessageLength sets the length of the buffer for octect parsing. +func WithMaxMessageLength(length int) ParserOption { + return func(p Parser) Parser { + p.WithMaxMessageLength(length) + return p + } +} diff --git a/syslog.go b/syslog.go index db628a2..e000794 100644 --- a/syslog.go +++ b/syslog.go @@ -15,6 +15,11 @@ type BestEfforter interface { HasBestEffort() bool } +// MaxMessager sets the max message size the parser should be able to parse +type MaxMessager interface { + WithMaxMessageLength(length int) +} + // Machine represent a FSM able to parse an entire syslog message and return it in an structured way. type Machine interface { Parse(input []byte) (Message, error) @@ -29,6 +34,7 @@ type Parser interface { Parse(r io.Reader) WithListener(ParserListener) BestEfforter + MaxMessager } // ParserOption represent the type of option setters for Parser instances. diff --git a/testing/testing.go b/testing/testing.go index 964ce4e..003b82a 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -57,6 +57,8 @@ var ( MaxMsgID = RandomBytes(32) // MaxMessage is a maximum length message that a RFC5424 syslog message can contain when all other fields are at their maximum length. MaxMessage = RandomBytes(7681) + // LongerMaxMessage is a maximum length message that a RFC5424 syslog message can contain when all other fields are at their maximum length. + LongerMaxMessage = RandomBytes(65018) ) // RightPad pads a string with spaces until the given limit, or it cuts the string to the given limit.