summaryrefslogtreecommitdiff
path: root/src/basic/log.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-09-30 16:17:12 +0200
committerLennart Poettering <lennart@poettering.net>2020-09-30 16:17:12 +0200
commitef9bddb79984aa1b9d605d44b8c0890e8289bef1 (patch)
tree4c2c75d117fc32dd8ca128644f6e8d0e36d940fa /src/basic/log.c
parent27ffec083140467a03f463a446c6d19dc5e437ab (diff)
downloadsystemd-ef9bddb79984aa1b9d605d44b8c0890e8289bef1.tar.gz
log: normalize log target condition check
THis doesn't change the condition's logic at all, but is an attempt to make things a bit more readable: instead of checking log_target != LOG_TARGET_AUTO let's actually list the targets where we want to consider journal/syslog/kmsg, to make things a bit less confusing. After all the message here is not to avoid them if LOG_TARGET_AUTO is set, but to definitely do them in the other cases.
Diffstat (limited to 'src/basic/log.c')
-rw-r--r--src/basic/log.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index 7c68258ea8..1d796c5180 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -267,28 +267,39 @@ int log_open(void) {
return 0;
}
- if (log_target != LOG_TARGET_AUTO || getpid_cached() == 1 || stderr_is_journal()) {
-
- if (!prohibit_ipc &&
- IN_SET(log_target, LOG_TARGET_AUTO,
- LOG_TARGET_JOURNAL_OR_KMSG,
- LOG_TARGET_JOURNAL)) {
- r = log_open_journal();
- if (r >= 0) {
- log_close_syslog();
- log_close_console();
- return r;
+ if (getpid_cached() == 1 ||
+ stderr_is_journal() ||
+ IN_SET(log_target,
+ LOG_TARGET_KMSG,
+ LOG_TARGET_JOURNAL,
+ LOG_TARGET_JOURNAL_OR_KMSG,
+ LOG_TARGET_SYSLOG,
+ LOG_TARGET_SYSLOG_OR_KMSG)) {
+
+ if (!prohibit_ipc) {
+ if (IN_SET(log_target,
+ LOG_TARGET_AUTO,
+ LOG_TARGET_JOURNAL_OR_KMSG,
+ LOG_TARGET_JOURNAL)) {
+
+ r = log_open_journal();
+ if (r >= 0) {
+ log_close_syslog();
+ log_close_console();
+ return r;
+ }
}
- }
- if (!prohibit_ipc &&
- IN_SET(log_target, LOG_TARGET_SYSLOG_OR_KMSG,
- LOG_TARGET_SYSLOG)) {
- r = log_open_syslog();
- if (r >= 0) {
- log_close_journal();
- log_close_console();
- return r;
+ if (IN_SET(log_target,
+ LOG_TARGET_SYSLOG_OR_KMSG,
+ LOG_TARGET_SYSLOG)) {
+
+ r = log_open_syslog();
+ if (r >= 0) {
+ log_close_journal();
+ log_close_console();
+ return r;
+ }
}
}