-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjournald.go
56 lines (52 loc) · 1.56 KB
/
journald.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
package hllogger
/*
Journald prefixes are syslog values (see syslog.h)
https://0pointer.de/blog/projects/journal-submit.html
*/
const (
// SystemdEmergPrefix is the string to prefix in Emergency for systemd-journald
SystemdEmergPrefix = "<0>"
// SystemdAlertPrefix is the string to prefix in Alert for systemd-journald
SystemdAlertPrefix = "<1>"
// SystemdCritPrefix is the string to prefix in Critical for systemd-journald
SystemdCritPrefix = "<2>"
// SystemdErrPrefix is the string to prefix in Error for systemd-journald
SystemdErrPrefix = "<3>"
// SystemdWarningPrefix is the string to prefix in Warning for systemd-journald
SystemdWarningPrefix = "<4>"
// SystemdNoticePrefix is the string to prefix in Notice for systemd-journald
SystemdNoticePrefix = "<5>"
// SystemdInfoPrefix is the string to prefix in Info for systemd-journald
SystemdInfoPrefix = "<6>"
// SystemdDebugPrefix is the string to prefix in Debug for systemd-journald
SystemdDebugPrefix = "<7>"
)
// SystemdPrefix returns the appropriate prefix for systemd-journald
func (ll LogLevel) SystemdPrefix() string {
switch ll {
case Debug:
return SystemdDebugPrefix
case Info:
return SystemdInfoPrefix
case Notice:
return SystemdNoticePrefix
case Warning:
return SystemdWarningPrefix
case Error:
return SystemdErrPrefix
case Critical:
return SystemdCritPrefix
case Alert:
return SystemdAlertPrefix
case Emergency:
return SystemdEmergPrefix
default:
return ""
}
}
func (hll *Logger) getJournaldPrefix(ll LogLevel) string {
if hll.journald {
return ll.SystemdPrefix()
}
return ""
}