From 1478ecd77da2f31cfd4852cd96e44d1dee4ec74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 15 Apr 2025 08:11:39 +0200 Subject: [PATCH] core: fix write of weechat.log to stdout with `weechat-headless --stdout` (issue #2247) --- CHANGELOG.md | 1 + src/core/core-log.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2db3e7765..77bbe4ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed +- core: fix write of weechat.log to stdout with `weechat-headless --stdout` ([#2247](https://github.com/weechat/weechat/issues/2247)) - core: add refresh of window title on buffer switch, when option weechat.look.window_title is set ## Version 4.6.1 (2025-04-09) diff --git a/src/core/core-log.c b/src/core/core-log.c index 279a4729e..5811dcf44 100644 --- a/src/core/core-log.c +++ b/src/core/core-log.c @@ -70,21 +70,22 @@ log_open (const char *filename, const char *mode) { weechat_log_file = stdout; } - else if (filename) - { - weechat_log_filename = strdup (filename); - } else { - string_asprintf (&weechat_log_filename, - "%s/%s", weechat_state_dir, WEECHAT_LOG_NAME); + if (filename) + { + weechat_log_filename = strdup (filename); + } + else + { + string_asprintf (&weechat_log_filename, + "%s/%s", weechat_state_dir, WEECHAT_LOG_NAME); + } + if (!weechat_log_filename) + return 0; + weechat_log_file = fopen (weechat_log_filename, mode); } - if (!weechat_log_filename) - return 0; - - weechat_log_file = fopen (weechat_log_filename, mode); - if (!weechat_log_file) { if (weechat_log_filename)