This repository has been archived by the owner on Sep 26, 2021. It is now read-only.
forked from saymedia/journald-cloudwatch-logs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
record.go
51 lines (44 loc) · 1.52 KB
/
record.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
package main
type Priority int
var (
EMERGENCY Priority = 0
ALERT Priority = 1
CRITICAL Priority = 2
ERROR Priority = 3
WARNING Priority = 4
NOTICE Priority = 5
INFO Priority = 6
DEBUG Priority = 7
)
var PriorityJSON = map[Priority][]byte{
EMERGENCY: []byte("\"EMERG\""),
ALERT: []byte("\"ALERT\""),
CRITICAL: []byte("\"CRITICAL\""),
ERROR: []byte("\"ERROR\""),
WARNING: []byte("\"WARNING\""),
NOTICE: []byte("\"NOTICE\""),
INFO: []byte("\"INFO\""),
DEBUG: []byte("\"DEBUG\""),
}
type Record struct {
InstanceId string `json:"instanceId,omitempty"`
TimeUsec int64 `json:"-"`
Command string `json:"cmdName,omitempty" journald:"SYSLOG_IDENTIFIER"`
Priority Priority `json:"priority" journald:"PRIORITY"`
Message string `json:"message" journald:"MESSAGE"`
MessageId string `json:"messageId,omitempty" journald:"MESSAGE_ID"`
}
type RecordSyslog struct {
Facility int `json:"facility,omitempty" journald:"SYSLOG_FACILITY"`
Identifier string `json:"ident,omitempty" journald:"SYSLOG_IDENTIFIER"`
PID int `json:"pid,omitempty" journald:"SYSLOG_PID"`
}
type RecordKernel struct {
Device string `json:"device,omitempty" journald:"_KERNEL_DEVICE"`
Subsystem string `json:"subsystem,omitempty" journald:"_KERNEL_SUBSYSTEM"`
SysName string `json:"sysName,omitempty" journald:"_UDEV_SYSNAME"`
DevNode string `json:"devNode,omitempty" journald:"_UDEV_DEVNODE"`
}
func (p Priority) MarshalJSON() ([]byte, error) {
return PriorityJSON[p], nil
}