]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/log.c
main: use a shorter default $PATH if /usr is merged
[thirdparty/systemd.git] / src / log.c
CommitLineData
d6c9574f 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
5899f3b7 2
a7334b09
LP
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
5899f3b7
LP
22#include <stdarg.h>
23#include <stdio.h>
c9b97d2a 24#include <errno.h>
16801e90
LP
25#include <unistd.h>
26#include <fcntl.h>
27#include <sys/socket.h>
28#include <sys/un.h>
5ba081b0 29#include <stddef.h>
5899f3b7
LP
30
31#include "log.h"
16801e90
LP
32#include "util.h"
33#include "macro.h"
5ba081b0 34#include "socket-util.h"
5899f3b7 35
bb99a35a
LP
36#define SNDBUF_SIZE (8*1024*1024)
37
16801e90 38static LogTarget log_target = LOG_TARGET_CONSOLE;
bbe63281 39static int log_max_level = LOG_INFO;
16801e90 40
843d2643 41static int console_fd = STDERR_FILENO;
16801e90
LP
42static int syslog_fd = -1;
43static int kmsg_fd = -1;
5ba081b0 44static int journal_fd = -1;
16801e90 45
c31e1495
LP
46static bool syslog_is_stream = false;
47
bbe63281
LP
48static bool show_color = false;
49static bool show_location = false;
50
35b8ca3a 51/* Akin to glibc's __abort_msg; which is private and we hence cannot
185986c6
LP
52 * use here. */
53static char *log_abort_msg = NULL;
54
843d2643
LP
55void log_close_console(void) {
56
57 if (console_fd < 0)
58 return;
16801e90 59
c8513d54
LP
60 if (getpid() == 1) {
61 if (console_fd >= 3)
62 close_nointr_nofail(console_fd);
63
843d2643 64 console_fd = -1;
16801e90
LP
65 }
66}
67
843d2643 68static int log_open_console(void) {
16801e90 69
843d2643 70 if (console_fd >= 0)
16801e90 71 return 0;
843d2643
LP
72
73 if (getpid() == 1) {
74
5ba081b0
LP
75 console_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
76 if (console_fd < 0) {
843d2643
LP
77 log_error("Failed to open /dev/console for logging: %s", strerror(-console_fd));
78 return console_fd;
79 }
80
35b8ca3a 81 log_debug("Successfully opened /dev/console for logging.");
843d2643
LP
82 } else
83 console_fd = STDERR_FILENO;
84
85 return 0;
86}
87
88void log_close_kmsg(void) {
89
90 if (kmsg_fd < 0)
91 return;
92
93 close_nointr_nofail(kmsg_fd);
94 kmsg_fd = -1;
95}
96
97static int log_open_kmsg(void) {
16801e90
LP
98
99 if (kmsg_fd >= 0)
100 return 0;
101
674f8283
LP
102 kmsg_fd = open("/dev/kmsg", O_WRONLY|O_NOCTTY|O_CLOEXEC);
103 if (kmsg_fd < 0) {
31a7034d 104 log_error("Failed to open /dev/kmsg for logging: %s", strerror(errno));
16801e90 105 return -errno;
c9b80453 106 }
16801e90 107
35b8ca3a 108 log_debug("Successfully opened /dev/kmsg for logging.");
0dae83f9 109
16801e90
LP
110 return 0;
111}
112
113void log_close_syslog(void) {
114
843d2643
LP
115 if (syslog_fd < 0)
116 return;
117
118 close_nointr_nofail(syslog_fd);
119 syslog_fd = -1;
16801e90
LP
120}
121
c31e1495 122static int create_log_socket(int type) {
c31e1495
LP
123 int fd;
124
632117b7
LP
125 /* All output to the syslog/journal fds we do asynchronously,
126 * and if the buffers are full we just drop the messages */
5ba081b0 127
632117b7 128 fd = socket(AF_UNIX, type|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
5ba081b0 129 if (fd < 0)
c31e1495
LP
130 return -errno;
131
bb99a35a
LP
132 fd_inc_sndbuf(fd, SNDBUF_SIZE);
133
c31e1495
LP
134 return fd;
135}
136
843d2643 137static int log_open_syslog(void) {
5ba081b0 138 union sockaddr_union sa;
16801e90
LP
139 int r;
140
16801e90
LP
141 if (syslog_fd >= 0)
142 return 0;
143
16801e90
LP
144 zero(sa);
145 sa.un.sun_family = AF_UNIX;
146 strncpy(sa.un.sun_path, "/dev/log", sizeof(sa.un.sun_path));
147
5ba081b0
LP
148 syslog_fd = create_log_socket(SOCK_DGRAM);
149 if (syslog_fd < 0) {
150 r = syslog_fd;
843d2643 151 goto fail;
16801e90
LP
152 }
153
c31e1495
LP
154 if (connect(syslog_fd, &sa.sa, sizeof(sa)) < 0) {
155 close_nointr_nofail(syslog_fd);
156
157 /* Some legacy syslog systems still use stream
158 * sockets. They really shouldn't. But what can we
159 * do... */
5ba081b0
LP
160 syslog_fd = create_log_socket(SOCK_STREAM);
161 if (syslog_fd < 0) {
162 r = syslog_fd;
c31e1495
LP
163 goto fail;
164 }
165
166 if (connect(syslog_fd, &sa.sa, sizeof(sa)) < 0) {
167 r = -errno;
168 goto fail;
169 }
170
171 syslog_is_stream = true;
172 } else
173 syslog_is_stream = false;
174
35b8ca3a 175 log_debug("Successfully opened syslog for logging.");
0dae83f9 176
16801e90 177 return 0;
843d2643
LP
178
179fail:
180 log_close_syslog();
31a7034d 181 log_debug("Failed to open syslog for logging: %s", strerror(-r));
843d2643
LP
182 return r;
183}
184
5ba081b0
LP
185void log_close_journal(void) {
186
187 if (journal_fd < 0)
188 return;
189
190 close_nointr_nofail(journal_fd);
191 journal_fd = -1;
192}
193
194static int log_open_journal(void) {
195 union sockaddr_union sa;
196 int r;
197
198 if (journal_fd >= 0)
199 return 0;
200
201 journal_fd = create_log_socket(SOCK_DGRAM);
202 if (journal_fd < 0) {
203 r = journal_fd;
204 goto fail;
205 }
206
207 zero(sa);
208 sa.un.sun_family = AF_UNIX;
209 strncpy(sa.un.sun_path, "/run/systemd/journal/socket", sizeof(sa.un.sun_path));
210
211 if (connect(journal_fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) {
212 r = -errno;
213 goto fail;
214 }
215
216 log_debug("Successfully opened journal for logging.");
217
218 return 0;
219
220fail:
221 log_close_journal();
222 log_debug("Failed to open journal for logging: %s", strerror(-r));
223 return r;
224}
225
843d2643
LP
226int log_open(void) {
227 int r;
228
229 /* If we don't use the console we close it here, to not get
230 * killed by SAK. If we don't use syslog we close it here so
231 * that we are not confused by somebody deleting the socket in
232 * the fs. If we don't use /dev/kmsg we still keep it open,
233 * because there is no reason to close it. */
234
9fae33d2 235 if (log_target == LOG_TARGET_NULL) {
5ba081b0 236 log_close_journal();
9fae33d2
LP
237 log_close_syslog();
238 log_close_console();
239 return 0;
240 }
241
bb7df0da
LP
242 if (log_target != LOG_TARGET_AUTO ||
243 getpid() == 1 ||
f41c094c 244 isatty(STDERR_FILENO) <= 0) {
bb7df0da
LP
245
246 if (log_target == LOG_TARGET_AUTO ||
5ba081b0
LP
247 log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
248 log_target == LOG_TARGET_JOURNAL) {
249 r = log_open_journal();
250 if (r >= 0) {
251 log_close_syslog();
bb7df0da
LP
252 log_close_console();
253 return r;
254 }
5ba081b0
LP
255 }
256
257 if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
258 log_target == LOG_TARGET_SYSLOG) {
259 r = log_open_syslog();
260 if (r >= 0) {
261 log_close_journal();
262 log_close_console();
263 return r;
264 }
265 }
266
bb7df0da 267 if (log_target == LOG_TARGET_AUTO ||
5ba081b0 268 log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
bb7df0da 269 log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
5ba081b0
LP
270 log_target == LOG_TARGET_KMSG) {
271 r = log_open_kmsg();
272 if (r >= 0) {
273 log_close_journal();
bb7df0da
LP
274 log_close_syslog();
275 log_close_console();
276 return r;
277 }
5ba081b0 278 }
bb7df0da 279 }
843d2643 280
5ba081b0 281 log_close_journal();
843d2643 282 log_close_syslog();
dcdf86bb
LP
283
284 /* Get the real /dev/console if we are PID=1, hence reopen */
285 log_close_console();
843d2643 286 return log_open_console();
16801e90
LP
287}
288
289void log_set_target(LogTarget target) {
290 assert(target >= 0);
291 assert(target < _LOG_TARGET_MAX);
292
293 log_target = target;
294}
295
871e5809 296void log_close(void) {
5ba081b0 297 log_close_journal();
871e5809 298 log_close_syslog();
5ba081b0
LP
299 log_close_kmsg();
300 log_close_console();
871e5809
LP
301}
302
4d8a7798 303void log_forget_fds(void) {
5ba081b0 304 console_fd = kmsg_fd = syslog_fd = journal_fd = -1;
4d8a7798
MS
305}
306
16801e90
LP
307void log_set_max_level(int level) {
308 assert((level & LOG_PRIMASK) == level);
309
310 log_max_level = level;
311}
312
843d2643 313static int write_to_console(
20c03b7b
LP
314 int level,
315 const char*file,
316 int line,
317 const char *func,
318 const char *buffer) {
5899f3b7 319
843d2643
LP
320 char location[64];
321 struct iovec iovec[5];
322 unsigned n = 0;
323 bool highlight;
5899f3b7 324
843d2643
LP
325 if (console_fd < 0)
326 return 0;
327
bbe63281 328 highlight = LOG_PRI(level) <= LOG_ERR && show_color;
843d2643
LP
329
330 zero(iovec);
674f8283
LP
331
332 if (show_location) {
333 snprintf(location, sizeof(location), "(%s:%u) ", file, line);
334 char_array_0(location);
bbe63281 335 IOVEC_SET_STRING(iovec[n++], location);
674f8283
LP
336 }
337
843d2643 338 if (highlight)
c1072ea0 339 IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_RED_ON);
843d2643
LP
340 IOVEC_SET_STRING(iovec[n++], buffer);
341 if (highlight)
61cbdc4b 342 IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_OFF);
843d2643
LP
343 IOVEC_SET_STRING(iovec[n++], "\n");
344
345 if (writev(console_fd, iovec, n) < 0)
346 return -errno;
5899f3b7 347
843d2643 348 return 1;
16801e90 349}
5899f3b7 350
16801e90
LP
351static int write_to_syslog(
352 int level,
353 const char*file,
354 int line,
355 const char *func,
843d2643 356 const char *buffer) {
16801e90
LP
357
358 char header_priority[16], header_time[64], header_pid[16];
16801e90
LP
359 struct iovec iovec[5];
360 struct msghdr msghdr;
361 time_t t;
362 struct tm *tm;
363
364 if (syslog_fd < 0)
843d2643 365 return 0;
16801e90 366
29db5834 367 snprintf(header_priority, sizeof(header_priority), "<%i>", level);
16801e90
LP
368 char_array_0(header_priority);
369
370 t = (time_t) (now(CLOCK_REALTIME) / USEC_PER_SEC);
371 if (!(tm = localtime(&t)))
372 return -EINVAL;
373
374 if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
375 return -EINVAL;
376
bb00e604 377 snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
16801e90
LP
378 char_array_0(header_pid);
379
16801e90
LP
380 zero(iovec);
381 IOVEC_SET_STRING(iovec[0], header_priority);
382 IOVEC_SET_STRING(iovec[1], header_time);
5b6319dc 383 IOVEC_SET_STRING(iovec[2], program_invocation_short_name);
16801e90
LP
384 IOVEC_SET_STRING(iovec[3], header_pid);
385 IOVEC_SET_STRING(iovec[4], buffer);
386
c899f8c6 387 /* When using syslog via SOCK_STREAM separate the messages by NUL chars */
c31e1495
LP
388 if (syslog_is_stream)
389 iovec[4].iov_len++;
390
16801e90
LP
391 zero(msghdr);
392 msghdr.msg_iov = iovec;
393 msghdr.msg_iovlen = ELEMENTSOF(iovec);
394
c31e1495
LP
395 for (;;) {
396 ssize_t n;
397
8f7f7a1b
MS
398 n = sendmsg(syslog_fd, &msghdr, MSG_NOSIGNAL);
399 if (n < 0)
c31e1495
LP
400 return -errno;
401
402 if (!syslog_is_stream ||
403 (size_t) n >= IOVEC_TOTAL_SIZE(iovec, ELEMENTSOF(iovec)))
404 break;
405
406 IOVEC_INCREMENT(iovec, ELEMENTSOF(iovec), n);
407 }
16801e90 408
843d2643 409 return 1;
16801e90
LP
410}
411
412static int write_to_kmsg(
413 int level,
414 const char*file,
415 int line,
416 const char *func,
843d2643 417 const char *buffer) {
16801e90
LP
418
419 char header_priority[16], header_pid[16];
16801e90
LP
420 struct iovec iovec[5];
421
422 if (kmsg_fd < 0)
843d2643 423 return 0;
16801e90 424
29db5834 425 snprintf(header_priority, sizeof(header_priority), "<%i>", level);
16801e90
LP
426 char_array_0(header_priority);
427
bb00e604 428 snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
16801e90
LP
429 char_array_0(header_pid);
430
16801e90
LP
431 zero(iovec);
432 IOVEC_SET_STRING(iovec[0], header_priority);
5b6319dc 433 IOVEC_SET_STRING(iovec[1], program_invocation_short_name);
16801e90
LP
434 IOVEC_SET_STRING(iovec[2], header_pid);
435 IOVEC_SET_STRING(iovec[3], buffer);
843d2643 436 IOVEC_SET_STRING(iovec[4], "\n");
16801e90
LP
437
438 if (writev(kmsg_fd, iovec, ELEMENTSOF(iovec)) < 0)
439 return -errno;
440
843d2643 441 return 1;
16801e90
LP
442}
443
5ba081b0
LP
444static int write_to_journal(
445 int level,
446 const char*file,
447 int line,
448 const char *func,
449 const char *buffer) {
450
451 char header[LINE_MAX];
452 struct iovec iovec[3];
453 struct msghdr mh;
454
455 if (journal_fd < 0)
456 return 0;
457
458 snprintf(header, sizeof(header),
459 "PRIORITY=%i\n"
460 "CODE_FILE=%s\n"
461 "CODE_LINE=%i\n"
462 "CODE_FUNCTION=%s\n"
463 "MESSAGE=",
464 LOG_PRI(level),
465 file,
466 line,
467 func);
468
469 char_array_0(header);
470
471 zero(iovec);
472 IOVEC_SET_STRING(iovec[0], header);
473 IOVEC_SET_STRING(iovec[1], buffer);
474 IOVEC_SET_STRING(iovec[2], "\n");
475
476 zero(mh);
477 mh.msg_iov = iovec;
478 mh.msg_iovlen = ELEMENTSOF(iovec);
479
480 if (sendmsg(journal_fd, &mh, MSG_NOSIGNAL) < 0)
481 return -errno;
482
483 return 1;
484}
485
843d2643
LP
486static int log_dispatch(
487 int level,
488 const char*file,
489 int line,
490 const char *func,
9726b29e 491 char *buffer) {
843d2643 492
9726b29e 493 int r = 0;
843d2643 494
9fae33d2
LP
495 if (log_target == LOG_TARGET_NULL)
496 return 0;
497
29db5834 498 /* Patch in LOG_DAEMON facility if necessary */
7d76f312
LP
499 if ((level & LOG_FACMASK) == 0)
500 level = LOG_DAEMON | LOG_PRI(level);
29db5834 501
9726b29e
LP
502 do {
503 char *e;
9499b235 504 int k = 0;
843d2643 505
9726b29e 506 buffer += strspn(buffer, NEWLINE);
843d2643 507
9726b29e
LP
508 if (buffer[0] == 0)
509 break;
843d2643 510
9726b29e
LP
511 if ((e = strpbrk(buffer, NEWLINE)))
512 *(e++) = 0;
843d2643 513
bb7df0da 514 if (log_target == LOG_TARGET_AUTO ||
5ba081b0
LP
515 log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
516 log_target == LOG_TARGET_JOURNAL) {
517
518 k = write_to_journal(level, file, line, func, buffer);
519 if (k < 0) {
520 if (k != -EAGAIN)
521 log_close_journal();
522 log_open_kmsg();
523 } else if (k > 0)
524 r++;
525 }
526
527 if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
9726b29e
LP
528 log_target == LOG_TARGET_SYSLOG) {
529
8f7f7a1b
MS
530 k = write_to_syslog(level, file, line, func, buffer);
531 if (k < 0) {
532 if (k != -EAGAIN)
533 log_close_syslog();
9726b29e 534 log_open_kmsg();
9499b235 535 } else if (k > 0)
9726b29e
LP
536 r++;
537 }
538
9499b235 539 if (k <= 0 &&
bb7df0da
LP
540 (log_target == LOG_TARGET_AUTO ||
541 log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
9499b235 542 log_target == LOG_TARGET_KMSG)) {
9726b29e 543
8f7f7a1b
MS
544 k = write_to_kmsg(level, file, line, func, buffer);
545 if (k < 0) {
9726b29e
LP
546 log_close_kmsg();
547 log_open_console();
9499b235 548 } else if (k > 0)
9726b29e
LP
549 r++;
550 }
551
8f7f7a1b
MS
552 if (k <= 0) {
553 k = write_to_console(level, file, line, func, buffer);
554 if (k < 0)
555 return k;
556 }
9726b29e
LP
557
558 buffer = e;
559 } while (buffer);
560
561 return r;
843d2643
LP
562}
563
2149e37c
LP
564int log_dump_internal(
565 int level,
566 const char*file,
567 int line,
568 const char *func,
569 char *buffer) {
570
571 int saved_errno, r;
572
573 /* This modifies the buffer... */
574
575 if (_likely_(LOG_PRI(level) > log_max_level))
576 return 0;
577
578 saved_errno = errno;
579 r = log_dispatch(level, file, line, func, buffer);
580 errno = saved_errno;
581
582 return r;
583}
584
843d2643 585int log_meta(
16801e90
LP
586 int level,
587 const char*file,
588 int line,
589 const char *func,
590 const char *format, ...) {
591
addab137 592 char buffer[LINE_MAX];
843d2643
LP
593 int saved_errno, r;
594 va_list ap;
16801e90 595
93a46b0b 596 if (_likely_(LOG_PRI(level) > log_max_level))
843d2643 597 return 0;
16801e90
LP
598
599 saved_errno = errno;
843d2643
LP
600
601 va_start(ap, format);
602 vsnprintf(buffer, sizeof(buffer), format, ap);
603 va_end(ap);
604
605 char_array_0(buffer);
606
607 r = log_dispatch(level, file, line, func, buffer);
185986c6 608 errno = saved_errno;
843d2643
LP
609
610 return r;
185986c6 611}
16801e90 612
a3f914b2
MS
613#pragma GCC diagnostic push
614#pragma GCC diagnostic ignored "-Wformat-nonliteral"
b7f33638 615_noreturn_ static void log_assert(const char *text, const char *file, int line, const char *func, const char *format) {
addab137 616 static char buffer[LINE_MAX];
185986c6 617
b7f33638 618 snprintf(buffer, sizeof(buffer), format, text, file, line, func);
185986c6
LP
619
620 char_array_0(buffer);
621 log_abort_msg = buffer;
622
843d2643 623 log_dispatch(LOG_CRIT, file, line, func, buffer);
185986c6 624 abort();
5899f3b7 625}
a3f914b2 626#pragma GCC diagnostic pop
34f0e866 627
b7f33638
MS
628void log_assert_failed(const char *text, const char *file, int line, const char *func) {
629 log_assert(text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
630}
631
632void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
633 log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
634}
635
34f0e866
LP
636int log_set_target_from_string(const char *e) {
637 LogTarget t;
638
5ba081b0
LP
639 t = log_target_from_string(e);
640 if (t < 0)
34f0e866
LP
641 return -EINVAL;
642
643 log_set_target(t);
644 return 0;
645}
646
647int log_set_max_level_from_string(const char *e) {
648 int t;
649
5ba081b0
LP
650 t = log_level_from_string(e);
651 if (t < 0)
652 return t;
34f0e866
LP
653
654 log_set_max_level(t);
655 return 0;
656}
657
658void log_parse_environment(void) {
659 const char *e;
660
661 if ((e = getenv("SYSTEMD_LOG_TARGET")))
662 if (log_set_target_from_string(e) < 0)
663 log_warning("Failed to parse log target %s. Ignoring.", e);
664
665 if ((e = getenv("SYSTEMD_LOG_LEVEL")))
666 if (log_set_max_level_from_string(e) < 0)
667 log_warning("Failed to parse log level %s. Ignoring.", e);
bbe63281 668
541d6159 669 if ((e = getenv("SYSTEMD_LOG_COLOR")))
bbe63281
LP
670 if (log_show_color_from_string(e) < 0)
671 log_warning("Failed to parse bool %s. Ignoring.", e);
672
dcdf86bb 673 if ((e = getenv("SYSTEMD_LOG_LOCATION")))
bbe63281
LP
674 if (log_show_location_from_string(e) < 0)
675 log_warning("Failed to parse bool %s. Ignoring.", e);
34f0e866
LP
676}
677
1adf1049
LP
678LogTarget log_get_target(void) {
679 return log_target;
680}
681
682int log_get_max_level(void) {
683 return log_max_level;
684}
685
bbe63281
LP
686void log_show_color(bool b) {
687 show_color = b;
688}
689
690void log_show_location(bool b) {
691 show_location = b;
692}
693
694int log_show_color_from_string(const char *e) {
695 int t;
696
5ba081b0
LP
697 t = parse_boolean(e);
698 if (t < 0)
699 return t;
bbe63281
LP
700
701 log_show_color(t);
702 return 0;
703}
704
705int log_show_location_from_string(const char *e) {
706 int t;
707
5ba081b0
LP
708 t = parse_boolean(e);
709 if (t < 0)
710 return t;
bbe63281
LP
711
712 log_show_location(t);
713 return 0;
714}
715
34f0e866
LP
716static const char *const log_target_table[] = {
717 [LOG_TARGET_CONSOLE] = "console",
34f0e866 718 [LOG_TARGET_KMSG] = "kmsg",
5ba081b0
LP
719 [LOG_TARGET_JOURNAL] = "journal",
720 [LOG_TARGET_JOURNAL_OR_KMSG] = "journal-or-kmsg",
721 [LOG_TARGET_SYSLOG] = "syslog",
843d2643 722 [LOG_TARGET_SYSLOG_OR_KMSG] = "syslog-or-kmsg",
5ba081b0
LP
723 [LOG_TARGET_AUTO] = "auto",
724 [LOG_TARGET_NULL] = "null"
34f0e866
LP
725};
726
727DEFINE_STRING_TABLE_LOOKUP(log_target, LogTarget);