forked from influxdata/go-syslog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
68 lines (60 loc) · 2.38 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package rfc3164
import (
"time"
syslog "github.com/influxdata/go-syslog/v3"
)
// WithBestEffort enables the best effort mode.
func WithBestEffort() syslog.MachineOption {
return func(m syslog.Machine) syslog.Machine {
m.WithBestEffort()
return m
}
}
// WithYear sets the strategy to decide the year for the Stamp timestamp of RFC 3164.
func WithYear(o YearOperator) syslog.MachineOption {
return func(m syslog.Machine) syslog.Machine {
m.(*machine).WithYear(o)
return m
}
}
// WithTimezone sets the strategy to decide the timezone to apply to the Stamp timestamp of RFC 3164.
func WithTimezone(loc *time.Location) syslog.MachineOption {
return func(m syslog.Machine) syslog.Machine {
m.(*machine).WithTimezone(loc)
return m
}
}
// WithLocaleTimezone sets the strategy to decide the timezone to apply to the Stamp timestamp of RFC 3164.
func WithLocaleTimezone(loc *time.Location) syslog.MachineOption {
return func(m syslog.Machine) syslog.Machine {
m.(*machine).WithLocaleTimezone(loc)
return m
}
}
// todo > WithStrictHostname() option - see RFC3164 page 10
// WithStrictHostname tells the parser to match the hostnames strictly as per RFC 3164 recommentations.
//
// The HOSTNAME field will contain only the hostname, the IPv4 address, or the IPv6 address of the originator of the message.
// The preferred value is the hostname.
// If the hostname is used, the HOSTNAME field MUST contain the hostname of the device as specified in STD 13 [4].
// It should be noted that this MUST NOT contain any embedded spaces.
// The Domain Name MUST NOT be included in the HOSTNAME field.
// If the IPv4 address is used, it MUST be shown as the dotted decimal notation as used in STD 13 [5].
// If an IPv6 address is used, any valid representation used in RFC 2373 [6] MAY be used.
// A single space character MUST also follow the HOSTNAME field.
// func WithStrictHostname() syslog.MachineOption {
// return func(m syslog.Machine) syslog.Machine {
// m.(*machine).WithStrictHostname()
// return m
// }
// }
// WithRFC3339 tells the parser to look for RFC3339 timestamps, too.
//
// It tells the parser to accept also RFC3339 timestamps even if they are not in the RFC3164 timestamp part.
// Note that WithYear option will be ignored when an RFC3339 timestamp will match.
func WithRFC3339() syslog.MachineOption {
return func(m syslog.Machine) syslog.Machine {
m.(*machine).WithRFC3339()
return m
}
}