summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-01 11:15:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-01 11:15:12 (GMT)
commit09f07c9a523dce7b8d7e013857f988f727f1a72b (patch)
treeca2e8badd81609070ef4aabd1b60174da7d6a114 /src
parentefbf67e4af709c9e9d27c288399654848a4bfda8 (diff)
Created an extra log category for external errors.
Diffstat (limited to 'src')
-rw-r--r--src/core/logs.c11
-rw-r--r--src/core/logs.h42
-rw-r--r--src/gui/panels/log.c17
3 files changed, 60 insertions, 10 deletions
diff --git a/src/core/logs.c b/src/core/logs.c
index 417039b..ec910e1 100644
--- a/src/core/logs.c
+++ b/src/core/logs.c
@@ -34,6 +34,9 @@
+/* ------------------------ EMISSIONS DE MESSAGES CLASSIQUES ------------------------ */
+
+
/* Tranche d'allocation pour les messages complexes */
#define VARIADIC_LOG_BUFSIZE 256
@@ -46,6 +49,11 @@ static void print_message_without_gui(LogMessageType, const char *);
+/* ---------------------------------------------------------------------------------- */
+/* EMISSIONS DE MESSAGES CLASSIQUES */
+/* ---------------------------------------------------------------------------------- */
+
+
/******************************************************************************
* *
* Paramètres : - *
@@ -251,8 +259,9 @@ static void print_message_without_gui(LogMessageType type, const char *msg)
prefix = FOREGROUND_RED "!" RESET;
break;
- case LMT_ERROR:
case LMT_BAD_BINARY:
+ case LMT_ERROR:
+ case LMT_EXT_ERROR:
prefix = BACKGROUND_RED "!" RESET;
break;
diff --git a/src/core/logs.h b/src/core/logs.h
index 238c3ba..27dd039 100644
--- a/src/core/logs.h
+++ b/src/core/logs.h
@@ -25,7 +25,10 @@
#define _CORE_LOGS_H
+#include <errno.h>
#include <stdarg.h>
+#include <string.h>
+#include <openssl/err.h>
#include <i18n.h>
@@ -38,14 +41,19 @@ typedef enum _LogMessageType
LMT_INFO, /* Information sur l'exécution */
LMT_PROCESS, /* Début de tâche quelconque */
LMT_WARNING, /* Avertissment à remonter */
- LMT_ERROR, /* Erreur de traitement */
LMT_BAD_BINARY, /* Binaire malformé */
+ LMT_ERROR, /* Erreur de traitement interne*/
+ LMT_EXT_ERROR, /* Erreur de traitement externe*/
LMT_COUNT
} LogMessageType;
+
+/* ------------------------ EMISSIONS DE MESSAGES CLASSIQUES ------------------------ */
+
+
/* Fournit la verbosité des messages système. */
LogMessageType get_log_verbosity(void);
@@ -63,4 +71,36 @@ void log_variadic_message(LogMessageType, const char *, ...);
+/* ------------------------ REMONTEE D'EVENEMENTS INATTENDUS ------------------------ */
+
+
+#define LOG_ERROR(tp, msg) \
+ log_variadic_message(tp, "[%s:%u] %s", __FUNCTION__, __LINE__, msg);
+
+#define LOG_ERROR_N(func) \
+ do \
+ { \
+ char __msg[1024]; \
+ char *__msg_ptr; \
+ __msg_ptr = strerror_r(errno, __msg, sizeof(__msg)); \
+ log_variadic_message(LMT_EXT_ERROR, "[%s:%u] %s: %s", __FUNCTION__, __LINE__, func, __msg_ptr); \
+ } \
+ while (0)
+
+#define LOG_ERROR_OPENSSL \
+ do \
+ { \
+ unsigned long __err; \
+ const char *__msg; \
+ __err = ERR_get_error(); \
+ __msg = ERR_reason_error_string(__err); \
+ if (__msg != NULL) \
+ log_variadic_message(LMT_EXT_ERROR, "[%s:%u] %s", __FUNCTION__, __LINE__, __msg); \
+ else \
+ log_variadic_message(LMT_EXT_ERROR, "[%s:%u] unamed error", __FUNCTION__, __LINE__); \
+ } \
+ while (0)
+
+
+
#endif /* _CORE_LOGS_H */
diff --git a/src/gui/panels/log.c b/src/gui/panels/log.c
index f0252e9..ffe8b42 100644
--- a/src/gui/panels/log.c
+++ b/src/gui/panels/log.c
@@ -292,30 +292,31 @@ static gboolean log_message(log_data *data)
-1);
break;
- case LMT_BAD_BINARY:
+ case LMT_PROCESS:
gtk_list_store_set(store, &iter,
- LGC_PICTURE, "gtk-dialog-warning",
+ LGC_PICTURE, "gtk-execute",
LGC_STRING, data->msg,
-1);
break;
- case LMT_PROCESS:
+ case LMT_WARNING:
gtk_list_store_set(store, &iter,
- LGC_PICTURE, "gtk-execute",
+ LGC_PICTURE, "gtk-dialog-warning",
LGC_STRING, data->msg,
-1);
break;
- case LMT_ERROR:
+ case LMT_BAD_BINARY:
gtk_list_store_set(store, &iter,
- LGC_PICTURE, "gtk-dialog-error",
+ LGC_PICTURE, "gtk-dialog-warning",
LGC_STRING, data->msg,
-1);
break;
- case LMT_WARNING:
+ case LMT_ERROR:
+ case LMT_EXT_ERROR:
gtk_list_store_set(store, &iter,
- LGC_PICTURE, "gtk-dialog-warning",
+ LGC_PICTURE, "gtk-dialog-error",
LGC_STRING, data->msg,
-1);
break;