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
path: root/src
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
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')
-rw-r--r--src/include/remmina/plugin.h5
-rw-r--r--src/remmina_log.c140
-rw-r--r--src/remmina_log.h12
-rw-r--r--src/remmina_plugin_manager.c5
4 files changed, 159 insertions, 3 deletions
diff --git a/src/include/remmina/plugin.h b/src/include/remmina/plugin.h
index 461ab783e..5c284f834 100644
--- a/src/include/remmina/plugin.h
+++ b/src/include/remmina/plugin.h
@@ -216,7 +216,12 @@ typedef struct _RemminaPluginService {
gboolean (*pref_get_ssh_parseconfig)(void);
guint (*pref_keymap_get_keyval)(const gchar *keymap, guint keyval);
+ void (*_remmina_info)(const gchar *fmt, ...);
+ void (*_remmina_message)(const gchar *fmt, ...);
void (*_remmina_debug)(const gchar *func, const gchar *fmt, ...);
+ void (*_remmina_warning)(const gchar *func, const gchar *fmt, ...);
+ void (*_remmina_error)(const gchar *func, const gchar *fmt, ...);
+ void (*_remmina_critical)(const gchar *func, const gchar *fmt, ...);
void (*log_print)(const gchar *text);
void (*log_printf)(const gchar *fmt, ...);
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);
}
-
diff --git a/src/remmina_log.h b/src/remmina_log.h
index dea77b891..c7b86d5e0 100644
--- a/src/remmina_log.h
+++ b/src/remmina_log.h
@@ -39,12 +39,22 @@
G_BEGIN_DECLS
-#define REMMINA_DEBUG(fmt, ...) _remmina_debug(__func__, fmt, ##__VA_ARGS__)
+#define REMMINA_INFO(fmt, ...) _remmina_info(fmt, ##__VA_ARGS__)
+#define REMMINA_MESSAGE(fmt, ...) _remmina_message(fmt, ##__VA_ARGS__)
+#define REMMINA_DEBUG(fmt, ...) _remmina_debug(__func__, fmt, ##__VA_ARGS__)
+#define REMMINA_WARNING(fmt, ...) _remmina_warning(__func__, fmt, ##__VA_ARGS__)
+#define REMMINA_ERROR(fmt, ...) _remmina_error(__func__, fmt, ##__VA_ARGS__)
+#define REMMINA_CRITICAL(fmt, ...) _remmina_critical(__func__, fmt, ##__VA_ARGS__)
void remmina_log_start(void);
gboolean remmina_log_running(void);
void remmina_log_print(const gchar *text);
+void _remmina_info(const gchar *fmt, ...);
+void _remmina_message(const gchar *fmt, ...);
void _remmina_debug(const gchar *fun, const gchar *fmt, ...);
+void _remmina_warning(const gchar *fun, const gchar *fmt, ...);
+void _remmina_error(const gchar *fun, const gchar *fmt, ...);
+void _remmina_critical(const gchar *fun, const gchar *fmt, ...);
void remmina_log_printf(const gchar *fmt, ...);
G_END_DECLS
diff --git a/src/remmina_plugin_manager.c b/src/remmina_plugin_manager.c
index fa3a41eb6..3e506ed53 100644
--- a/src/remmina_plugin_manager.c
+++ b/src/remmina_plugin_manager.c
@@ -238,7 +238,12 @@ RemminaPluginService remmina_plugin_manager_service =
remmina_pref_get_ssh_parseconfig,
remmina_pref_keymap_get_keyval,
+ _remmina_info,
+ _remmina_message,
_remmina_debug,
+ _remmina_warning,
+ _remmina_error,
+ _remmina_critical,
remmina_log_print,
remmina_log_printf,