-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.go
81 lines (66 loc) · 1.45 KB
/
message.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
69
70
71
72
73
74
75
76
77
78
79
80
81
// Original work Copyright (c) 2018, InfluxData Inc.
package legacysyslog
import (
"time"
"github.com/influxdata/go-syslog/v3"
)
type CiscoTimeClockMode int8
const (
CiscoTimeClockModeUnset CiscoTimeClockMode = iota
CiscoTimeClockModeSynced
CiscoTimeClockModeUnsynced
)
type syslogMessage struct {
prioritySet bool
ciscoSequenceIDSet bool
timestampSet bool
hostnameSet bool
tagSet bool
contentSet bool
messageSet bool
ciscoTimestampExt CiscoTimeClockMode
priority uint8
ciscoSequenceID string
timestamp time.Time
hostname string
tag string
content string
message string
}
type SyslogMessage struct {
syslog.Base
CiscoSequenceID *string
CiscoTimestampExt CiscoTimeClockMode
Tag *string
Content *string
}
var _ syslog.Message = &SyslogMessage{}
func (sm *syslogMessage) export() *SyslogMessage {
out := &SyslogMessage{
CiscoTimestampExt: sm.ciscoTimestampExt,
}
if sm.prioritySet {
out.ComputeFromPriority(sm.priority)
}
if sm.ciscoSequenceIDSet {
out.CiscoSequenceID = &sm.ciscoSequenceID
}
if sm.timestampSet {
out.Timestamp = &sm.timestamp
}
if sm.hostnameSet {
out.Hostname = &sm.hostname
}
if sm.tagSet {
out.Tag = &sm.tag
out.Appname = out.Tag
}
if sm.contentSet {
out.Content = &sm.content
out.ProcID = out.Content
}
if sm.messageSet {
out.Message = &sm.message
}
return out
}