|
@@ -7,25 +7,26 @@
|
|
#include "ua_types_generated.h"
|
|
#include "ua_types_generated.h"
|
|
#include "ua_types_generated_handling.h"
|
|
#include "ua_types_generated_handling.h"
|
|
|
|
|
|
|
|
+#ifdef UA_ENABLE_MULTITHREADING
|
|
|
|
+#include <pthread.h>
|
|
|
|
+static pthread_mutex_t printf_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
+#endif
|
|
|
|
+
|
|
const char *LogLevelNames[6] = {"trace", "debug", "info", "warning", "error", "fatal"};
|
|
const char *LogLevelNames[6] = {"trace", "debug", "info", "warning", "error", "fatal"};
|
|
const char *LogCategoryNames[6] = {"network", "channel", "session", "server", "client", "userland"};
|
|
const char *LogCategoryNames[6] = {"network", "channel", "session", "server", "client", "userland"};
|
|
|
|
|
|
-#if (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 6) || defined(__clang__)
|
|
|
|
-# pragma GCC diagnostic push
|
|
|
|
-# pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-void UA_Log_Stdout(UA_LogLevel level, UA_LogCategory category, const char *msg, ...) {
|
|
|
|
|
|
+void
|
|
|
|
+UA_Log_Stdout(UA_LogLevel level, UA_LogCategory category,
|
|
|
|
+ const char *msg, va_list args) {
|
|
UA_String t = UA_DateTime_toString(UA_DateTime_now());
|
|
UA_String t = UA_DateTime_toString(UA_DateTime_now());
|
|
|
|
+#ifdef UA_ENABLE_MULTITHREADING
|
|
|
|
+ pthread_mutex_lock(&printf_mutex);
|
|
|
|
+#endif
|
|
printf("[%.23s] %s/%s\t", t.data, LogLevelNames[level], LogCategoryNames[category]);
|
|
printf("[%.23s] %s/%s\t", t.data, LogLevelNames[level], LogCategoryNames[category]);
|
|
UA_ByteString_deleteMembers(&t);
|
|
UA_ByteString_deleteMembers(&t);
|
|
- va_list ap;
|
|
|
|
- va_start(ap, msg);
|
|
|
|
- vprintf(msg, ap);
|
|
|
|
- va_end(ap);
|
|
|
|
|
|
+ vprintf(msg, args);
|
|
printf("\n");
|
|
printf("\n");
|
|
-}
|
|
|
|
-
|
|
|
|
-#if (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 6) || defined(__clang__)
|
|
|
|
-# pragma GCC diagnostic pop
|
|
|
|
|
|
+#ifdef UA_ENABLE_MULTITHREADING
|
|
|
|
+ pthread_mutex_unlock(&printf_mutex);
|
|
#endif
|
|
#endif
|
|
|
|
+}
|