summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2020-10-01 10:51:19 +0200
committerGitHub <noreply@github.com>2020-10-01 10:51:19 +0200
commit8ce3de991b58da019fa377930888a5ca50df644a (patch)
treed2b3ddfef8f6503fd09b10aa91c2e3d988e017a6 /src/basic
parentfabf8777051aedf0b1cdfe1d28a4c80a7f3358a4 (diff)
parentdee29aeb5909f4f5604012ced250488286b8d468 (diff)
downloadsystemd-8ce3de991b58da019fa377930888a5ca50df644a.tar.gz
Merge pull request #17214 from poettering/log-generator-fix
fix logging in generators
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/log.c51
-rw-r--r--src/basic/log.h2
2 files changed, 32 insertions, 21 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;
+ }
}
}
diff --git a/src/basic/log.h b/src/basic/log.h
index c65419b699..ce8bb42ea1 100644
--- a/src/basic/log.h
+++ b/src/basic/log.h
@@ -30,7 +30,7 @@ typedef enum LogTarget{
LOG_TARGET_JOURNAL_OR_KMSG,
LOG_TARGET_SYSLOG,
LOG_TARGET_SYSLOG_OR_KMSG,
- LOG_TARGET_AUTO, /* console if stderr is tty, JOURNAL_OR_KMSG otherwise */
+ LOG_TARGET_AUTO, /* console if stderr is not journal, JOURNAL_OR_KMSG otherwise */
LOG_TARGET_NULL,
_LOG_TARGET_MAX,
_LOG_TARGET_INVALID = -1