Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-08-25 15:38:40 +0300
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-09-20 15:51:18 +0300
commit06bc4acf3adc14a69eb9bad4402a40c81aab3fd6 (patch)
treee0918886bdecb20384a1e03239bdbbe9b4473b90 /src/remmina_log.c
parent7d35dfbb274cf501b5422927b1e50f770c614f76 (diff)
Add _remmina_{info, message, debug, warning, error, critical} log functions; Add REMMINA_PLUGIN_{..., ...} defines.
GLib oriented log functions printing both to Remmina's own debug window and to stdout. Newline are always added and can't be turned off. Thats a GLib flaw. !!! Calling g_error (_remmina_error) crashes Remmina purposefully with a trap signal !!!
Diffstat (limited to 'src/remmina_log.c')
-rw-r--r--src/remmina_log.c140
1 files changed, 138 insertions, 2 deletions
diff --git a/src/remmina_log.c b/src/remmina_log.c
index 5aa105d1e..f208338e3 100644
--- a/src/remmina_log.c
+++ b/src/remmina_log.c
@@ -178,6 +178,8 @@ static gboolean remmina_log_print_real(gpointer data)
return FALSE;
}
+// Only prints into Remmina's own debug window. (Not stdout!)
+// See _remmina_{debug, info, error, critical, warning}
void remmina_log_print(const gchar *text)
{
TRACE_CALL(__func__);
@@ -187,6 +189,54 @@ void remmina_log_print(const gchar *text)
IDLE_ADD(remmina_log_print_real, g_strdup(text));
}
+void _remmina_info(const gchar *fmt, ...)
+{
+ TRACE_CALL(__func__);
+
+ va_list args;
+ g_autofree gchar *text;
+ va_start(args, fmt);
+ text = g_strdup_vprintf(fmt, args);
+ va_end(args);
+
+ // always appends newline
+ g_info ("%s", text);
+
+ g_autofree gchar *buf_tmp = g_strconcat(text, "\n", NULL);
+ /* freed in remmina_log_print_real */
+ gchar *bufn = g_strconcat("(INFO) - ", buf_tmp, NULL);
+
+ if (!log_window) {
+ free(bufn);
+ return;
+ }
+ IDLE_ADD(remmina_log_print_real, bufn);
+}
+
+void _remmina_message(const gchar *fmt, ...)
+{
+ TRACE_CALL(__func__);
+
+ va_list args;
+ g_autofree gchar *text;
+ va_start(args, fmt);
+ text = g_strdup_vprintf(fmt, args);
+ va_end(args);
+
+ // always appends newline
+ g_message ("%s", text);
+
+ 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);
+}
+
/**
* Print a string in the Remmina Debug Windows and in the terminal.
* The string will be visible in the terminal if G_MESSAGES_DEBUG=all
@@ -205,10 +255,12 @@ void _remmina_debug(const gchar *fun, const gchar *fmt, ...)
g_autofree gchar *buf = g_strconcat("(", fun, ") - ", text, NULL);
g_free(text);
+ // always appends newline
g_debug ("%s", buf);
+ g_autofree gchar *buf_tmp = g_strconcat(buf, "\n", NULL);
/* freed in remmina_log_print_real */
- gchar *bufn = g_strconcat(buf, "\n", NULL);
+ gchar *bufn = g_strconcat("(DEBUG) - ", buf_tmp, NULL);
if (!log_window) {
free(bufn);
@@ -217,6 +269,91 @@ void _remmina_debug(const gchar *fun, const gchar *fmt, ...)
IDLE_ADD(remmina_log_print_real, bufn);
}
+void _remmina_warning(const gchar *fun, const gchar *fmt, ...)
+{
+ TRACE_CALL(__func__);
+
+ va_list args;
+ gchar *text;
+ va_start(args, fmt);
+ text = g_strdup_vprintf(fmt, args);
+ va_end(args);
+
+ g_autofree gchar *buf = g_strconcat("(", fun, ") - ", text, NULL);
+ g_free(text);
+
+ // always appends newline
+ g_warning ("%s", buf);
+
+ 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);
+}
+
+// !!! Calling this function will crash Remmina !!!
+// !!! purposefully and send a trap signal !!!
+void _remmina_error(const gchar *fun, const gchar *fmt, ...)
+{
+ TRACE_CALL(__func__);
+
+ va_list args;
+ gchar *text;
+ va_start(args, fmt);
+ text = g_strdup_vprintf(fmt, args);
+ va_end(args);
+
+ g_autofree gchar *buf = g_strconcat("(", fun, ") - ", text, NULL);
+ g_free(text);
+
+ // always appends newline
+ g_error ("%s", buf);
+
+ 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);
+}
+
+void _remmina_critical(const gchar *fun, const gchar *fmt, ...)
+{
+ TRACE_CALL(__func__);
+
+ va_list args;
+ gchar *text;
+ va_start(args, fmt);
+ text = g_strdup_vprintf(fmt, args);
+ va_end(args);
+
+ g_autofree gchar *buf = g_strconcat("(", fun, ") - ", text, NULL);
+ g_free(text);
+
+ // always appends newline
+ g_critical ("%s", buf);
+
+ 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}
void remmina_log_printf(const gchar *fmt, ...)
{
TRACE_CALL(__func__);
@@ -231,4 +368,3 @@ void remmina_log_printf(const gchar *fmt, ...)
IDLE_ADD(remmina_log_print_real, text);
}
-