diff --git a/rfc3164/model.go b/rfc3164/model.go index 0e230b4..d5e3083 100644 --- a/rfc3164/model.go +++ b/rfc3164/model.go @@ -25,12 +25,56 @@ func NewPRI(value byte) (PRI, error) { return PRI{value: value}, nil } +type Facility byte + +// Definition taken from https://datatracker.ietf.org/doc/html/rfc3164#section-4.1.1 +const ( + FacilityKernel Facility = iota + FacilityUser + FacilityMail + FacilitySystem + FacilityAuth + FacilitySyslog + FacilityLPR + FacilityNews + FacilityUUCP + FacilityClock + FacilityAuth2 + FacilityFTP + FacilityNTP + FacilityLogAudit + FacilityLogAlert + FacilityClock2 + FacilityLocal0 + FacilityLocal1 + FacilityLocal2 + FacilityLocal3 + FacilityLocal4 + FacilityLocal5 + FacilityLocal6 + FacilityLocal7 +) + // Facility returns the facility value of the PRI. -func (p PRI) Facility() byte { - return p.value & 0xF8 >> 3 +func (p PRI) Facility() Facility { + return Facility(p.value & 0xF8 >> 3) } +type Severity byte + +// Definition taken from https://datatracker.ietf.org/doc/html/rfc3164#section-4.1.1 +const ( + SeverityEmergency Severity = iota + SeverityAlert + SeverityCritical + SeverityError + SeverityWarning + SeverityNotice + SeverityInformational + SeverityDebug +) + // Severity returns the severity value of the PRI. -func (p PRI) Severity() byte { - return p.value & 0x07 +func (p PRI) Severity() Severity { + return Severity(p.value & 0x07) } diff --git a/rfc5424/model.go b/rfc5424/model.go index 8aeb6be..0d82aaa 100644 --- a/rfc5424/model.go +++ b/rfc5424/model.go @@ -28,14 +28,58 @@ func NewPRI(value byte) (PRI, error) { return PRI{value: value}, nil } +type Facility byte + +// Definition taken from https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 +const ( + FacilityKernel Facility = iota + FacilityUser + FacilityMail + FacilitySystem + FacilityAuth + FacilitySyslog + FacilityLPR + FacilityNews + FacilityUUCP + FacilityClock + FacilityAuth2 + FacilityFTP + FacilityNTP + FacilityLogAudit + FacilityLogAlert + FacilityClock2 + FacilityLocal0 + FacilityLocal1 + FacilityLocal2 + FacilityLocal3 + FacilityLocal4 + FacilityLocal5 + FacilityLocal6 + FacilityLocal7 +) + // Facility returns the facility value of the PRI. -func (p PRI) Facility() byte { - return p.value & 0xF8 >> 3 +func (p PRI) Facility() Facility { + return Facility(p.value & 0xF8 >> 3) } +type Severity byte + +// Definition taken from https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 +const ( + SeverityEmergency Severity = iota + SeverityAlert + SeverityCritical + SeverityError + SeverityWarning + SeverityNotice + SeverityInformational + SeverityDebug +) + // Severity returns the severity value of the PRI. -func (p PRI) Severity() byte { - return p.value & 0x07 +func (p PRI) Severity() Severity { + return Severity(p.value & 0x07) } // StructuredDataElement represents a structured data element in a syslog message.