Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Update example_test.go #37

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions rfc3164/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,45 @@ func Example_stamp_also_when_rfc3339() {
// }
// })
}

func Example_custom_stamp1() {
i := []byte(`<134>Jul 16 2020 02:15:13 an 200050021 id=OS time="2020-7-16 02:15:13"`)
p := NewParser()
m, _ := p.Parse(i)
output(m)
// Output:
// (*rfc3164.SyslogMessage)({
// Base: (syslog.Base) {
// Facility: (*uint8)(16),
// Severity: (*uint8)(6),
// Priority: (*uint8)(134),
// Timestamp: (*time.Time)(2020-07-16 02:15:13 +0000 UTC),
// Hostname: (*string)((len=2) "an"),
// Appname: (*string)(<nil>),
// ProcID: (*string)(<nil>),
// MsgID: (*string)(<nil>),
// Message: (*string)((len=43) "200050021 id=OS time=\"2020-7-16 02:15:13\"")
// }
// })
}

func Example_custom_stamp2() {
i := []byte(`<134>2020 Jul 16 02:15:13 an 200050021 id=OS time="2020-7-16 02:15:13"`)
p := NewParser()
m, _ := p.Parse(i)
output(m)
// Output:
// (*rfc3164.SyslogMessage)({
// Base: (syslog.Base) {
// Facility: (*uint8)(16),
// Severity: (*uint8)(6),
// Priority: (*uint8)(134),
// Timestamp: (*time.Time)(2020-07-16 02:15:13 +0000 UTC),
// Hostname: (*string)((len=2) "an"),
// Appname: (*string)(<nil>),
// ProcID: (*string)(<nil>),
// MsgID: (*string)(<nil>),
// Message: (*string)((len=43) "200050021 id=OS time=\"2020-7-16 02:15:13\"")
// }
// })
}