Commit 587b5e5
journald: Set syslog identifier (#1822)
Set the `SYSLOG_IDENTIFIER` field on all events. I noticed that the
subscriber didn't do this so far.
## Motivation
The identifier is used with `journalctl -t`, and while it's normally
better to filter by unit with `journalctl -u` the identifier is still
nice for processes that are not started through systemd units.
Upstream does this as well, see [here]:

`program_invocation_short_name` is a glibc variable which holds the file
name of the current executable; I tried to replicate this behaviour in
Rust.
## Solution
Add a syslog identifier field to the subscriber, defaulting to the
filename of the current executable, and write this value as
`SYSLOG_IDENTIFIER` with every event. It's not written for spans, because
it's a global value and inevitably the same for each span.
[here]: https://github.com/systemd/systemd/blob/81218ac1e14b4b50b4337938bcf55cacc76f0728/src/libsystemd/sd-journal/journal-send.c#L2701 parent 13771cb commit 587b5e5
1 file changed
+38
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
104 | 112 | | |
105 | 113 | | |
106 | 114 | | |
| |||
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
124 | 158 | | |
125 | 159 | | |
126 | 160 | | |
| |||
224 | 258 | | |
225 | 259 | | |
226 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
227 | 265 | | |
228 | 266 | | |
229 | 267 | | |
| |||
0 commit comments