influxdata / go-syslog

Blazing fast syslog parser
MIT License
477 stars 69 forks source link

Syslog builder using ragel #11

Closed leodido closed 6 years ago

leodido commented 6 years ago

The aim of this PR is to introduce a syslog builder based on ragel.

This way, using the builder API, the user can create syslog messages which parts are syntactically and semantically valid.

Incorrect input values during the creation are ignored. The builder accounts also for nil values, distinguishing them from 0-values. it has a fluent interface, to be able to chain setters.

To do so I extracted the RFC5424 common pieces into a base ragel grammar which is then used within the parser and within the builder.

The API is:

With this we could make the SyslogMessage struct fields private, providing getters (as done for facility and severity) to access their values and forcing the user to use the builder API to construct SyslogMessage instances. What do you think about this @goller ?

Other notable methods of SyslogMessage are:

Other methods we could introduce but I am not sure about are:

leodido commented 6 years ago

Ready to merge if @goller approves it.