diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-08-27 16:06:19 +0300 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-09-20 15:51:18 +0300 |
commit | d093703882c24d4e42b1f64982350e33c79e78cd (patch) | |
tree | 54d24c9049d6cc3e23009b21b0195d070992ef6c | |
parent | fb1f92eda624f7c2ec80293334b9396f44fc07e8 (diff) |
remmina_log.c: Optimize _remmina_{LOGLEVEL} functions.
Do not create a new string buffer if not using Remmina's own debug window.
-rw-r--r-- | src/remmina_log.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/remmina_log.c b/src/remmina_log.c index f208338e3..0b9d389e3 100644 --- a/src/remmina_log.c +++ b/src/remmina_log.c @@ -226,14 +226,14 @@ void _remmina_message(const gchar *fmt, ...) // always appends newline g_message ("%s", text); + if (!log_window) { + return; + } + g_autofree gchar *buf_tmp = g_strconcat(text, "\n", NULL); /* freed in remmina_log_print_real */ gchar *bufn = g_strconcat("(MESSAGE) - ", buf_tmp, NULL); - if (!log_window) { - free(bufn); - return; - } IDLE_ADD(remmina_log_print_real, bufn); } @@ -258,14 +258,14 @@ void _remmina_debug(const gchar *fun, const gchar *fmt, ...) // always appends newline g_debug ("%s", buf); + if (!log_window) { + return; + } + g_autofree gchar *buf_tmp = g_strconcat(buf, "\n", NULL); /* freed in remmina_log_print_real */ gchar *bufn = g_strconcat("(DEBUG) - ", buf_tmp, NULL); - if (!log_window) { - free(bufn); - return; - } IDLE_ADD(remmina_log_print_real, bufn); } @@ -285,14 +285,14 @@ void _remmina_warning(const gchar *fun, const gchar *fmt, ...) // always appends newline g_warning ("%s", buf); + if (!log_window) { + return; + } + g_autofree gchar *buf_tmp = g_strconcat(buf, "\n", NULL); /* freed in remmina_log_print_real */ gchar *bufn = g_strconcat("(WARN) - ", buf_tmp, NULL); - if (!log_window) { - free(bufn); - return; - } IDLE_ADD(remmina_log_print_real, bufn); } @@ -314,14 +314,14 @@ void _remmina_error(const gchar *fun, const gchar *fmt, ...) // always appends newline g_error ("%s", buf); + if (!log_window) { + return; + } + g_autofree gchar *buf_tmp = g_strconcat(buf, "\n", NULL); /* freed in remmina_log_print_real */ gchar *bufn = g_strconcat("(ERROR) - ", buf_tmp, NULL); - if (!log_window) { - free(bufn); - return; - } IDLE_ADD(remmina_log_print_real, bufn); } @@ -341,19 +341,19 @@ void _remmina_critical(const gchar *fun, const gchar *fmt, ...) // always appends newline g_critical ("%s", buf); + if (!log_window) { + return; + } + g_autofree gchar *buf_tmp = g_strconcat(buf, "\n", NULL); /* freed in remmina_log_print_real */ gchar *bufn = g_strconcat("(CRIT) - ", buf_tmp, NULL); - if (!log_window) { - free(bufn); - return; - } IDLE_ADD(remmina_log_print_real, bufn); } // Only prints into Remmina's own debug window. (Not stdout!) -// See _remmina_{debug, info, error, critical, warning} +// See _remmina_{message, info, debug warning, error, critical} void remmina_log_printf(const gchar *fmt, ...) { TRACE_CALL(__func__); |