- https://github.com/abrt/abrt/issues/607

Signed-off-by: Jakub Filak <[email protected]>
---
 src/cli/cli-report.c        |  5 ++---
 src/gui-wizard-gtk/wizard.c | 13 ++++++++++---
 src/include/client.h        |  3 +++
 src/lib/client.c            | 13 +++++++++++++
 src/lib/run_event.c         |  2 +-
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
index ab4fb92..3923d60 100644
--- a/src/cli/cli-report.c
+++ b/src/cli/cli-report.c
@@ -472,7 +472,7 @@ struct logging_state {
 
 static char *do_log(char *log_line, void *param)
 {
-    log("%s", log_line);
+    client_log(log_line);
     return log_line;
 }
 
@@ -481,8 +481,7 @@ static char *do_log_and_check_for_THANKYOU(char *log_line, 
void *param)
     struct logging_state *l_state = param;
     l_state->saw_THANKYOU |= (strcmp("THANKYOU", log_line) == 0);
     l_state->output_was_produced |= (log_line[0] != '\0');
-    log("%s", log_line);
-    return log_line;
+    return do_log(log_line, param);
 }
 
 static int export_config_and_run_event(
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index b048823..4939dd2 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1527,12 +1527,19 @@ static void terminate_event_chain()
 
 static void update_command_run_log(const char* message, struct 
analyze_event_data *evd)
 {
-    gtk_label_set_text(g_lbl_event_log, message);
+    const bool it_is_a_dot = (message[0] == '.' && message[1] == '\0');
 
-    char *log_msg = xasprintf("%s\n", message);
+    if (!it_is_a_dot)
+        gtk_label_set_text(g_lbl_event_log, message);
+
+    /* Don't append new line behind single dot */
+    const char *log_msg = it_is_a_dot ? message : xasprintf("%s\n", message);
     append_to_textview(evd->tv_log, log_msg);
     save_to_event_log(evd, log_msg);
-    free(log_msg);
+
+    /* Because of single dot, see lines above */
+    if (log_msg != message)
+        free((void *)log_msg);
 }
 
 static void run_event_gtk_error(const char *error_line, void *param)
diff --git a/src/include/client.h b/src/include/client.h
index dc453b7..f2185d9 100644
--- a/src/include/client.h
+++ b/src/include/client.h
@@ -58,6 +58,9 @@ char *ask_password(const char *question);
 #define alert libreport_alert
 void alert(const char *message);
 
+#define client_log libreport_client_log
+void client_log(const char *message);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/lib/client.c b/src/lib/client.c
index d1ada22..b7691d0 100644
--- a/src/lib/client.c
+++ b/src/lib/client.c
@@ -163,3 +163,16 @@ void alert(const char *message)
     puts(message);
     fflush(stdout);
 }
+
+void client_log(const char *message)
+{
+    if (message != NULL
+        && (message[0] == '.' && message[1] == '\0')
+        && !is_slave_mode()
+       )
+        putchar('.');
+    else
+        printf("%s\n", message);
+
+    fflush(stdout);
+}
diff --git a/src/lib/run_event.c b/src/lib/run_event.c
index ea90029..6cd055c 100644
--- a/src/lib/run_event.c
+++ b/src/lib/run_event.c
@@ -744,7 +744,7 @@ char *run_event_stdio_ask_password(const char *msg, void 
*param)
 
 static char *run_event_stdio_log(char *log_line, void *param)
 {
-    printf("%s\n", log_line);
+    client_log(log_line);
     return log_line;
 }
 
-- 
1.8.1.2

Reply via email to