summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-07-21 13:20:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-07-21 13:20:15 (GMT)
commit6ae34a5cd11f6af7d94bde1b4bb2cdd43e79466f (patch)
tree5602c9c10e280919ac9bb5eb6c32c9ae9a13212e /src/plugins
parent1afa87db3d1d1b417289488e17cecf43952b81f0 (diff)
Simplified the logging system for plugins.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugin-int.h2
-rw-r--r--src/plugins/plugin.c36
2 files changed, 8 insertions, 30 deletions
diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h
index ee7c442..03040d1 100644
--- a/src/plugins/plugin-int.h
+++ b/src/plugins/plugin-int.h
@@ -33,7 +33,7 @@
#include "plugin-def.h"
#include "../analysis/content.h"
#include "../common/bits.h"
-#include "../gui/panels/log.h"
+#include "../core/logs.h"
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 3d1350d..d1e90c8 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -664,43 +664,21 @@ void g_plugin_module_log_simple_message(const GPluginModule *plugin, LogMessageT
void g_plugin_module_log_variadic_message(const GPluginModule *plugin, LogMessageType type, const char *fmt, ...)
{
- size_t len; /* Taille tampon disponible */
- char *buffer; /* Tampon du msg reconstitué */
- int ret; /* Bilan d'une impression */
- char *ptr; /* Nouvelle allocation */
va_list ap; /* Liste d'arguments variable */
+ char *buffer; /* Tampon du msg reconstitué */
- len = VARIADIC_LOG_BUFSIZE;
- buffer = calloc(len, sizeof(char));
+ va_start(ap, fmt);
+ buffer = build_variadic_message(fmt, ap);
+ va_end(ap);
- while (buffer != NULL)
+ if (buffer != NULL)
{
- va_start(ap, fmt);
- ret = vsnprintf(buffer, len, fmt, ap);
- va_end(ap);
-
- if (ret >= 0 && ret < len) break;
-
- else
- {
- if (ret > -1) len += 1; /* glibc 2.1 */
- else len *= 2; /* glibc 2.0 */
+ g_plugin_module_log_simple_message(plugin, type, buffer);
- if ((ptr = realloc(buffer, len)) == NULL)
- {
- free(buffer);
- buffer = NULL;
- }
- else buffer = ptr;
-
- }
+ free(buffer);
}
- g_plugin_module_log_simple_message(plugin, type, buffer);
-
- free(buffer);
-
}