Commit d0badaa4 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/app/logger/Logger): log thread

parent 4e56e23c
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <bctoolbox/logging.h> #include <bctoolbox/logging.h>
#include <linphone/linphonecore.h> #include <linphone/linphonecore.h>
#include <QDateTime> #include <QDateTime>
#include <QThread>
#include "../../Utils.hpp" #include "../../Utils.hpp"
#include "../paths/Paths.hpp" #include "../paths/Paths.hpp"
...@@ -43,7 +44,7 @@ ...@@ -43,7 +44,7 @@
#define PURPLE "" #define PURPLE ""
#define RED "" #define RED ""
#define RESET "" #define RESET ""
#endif // ifdef __linux__ #endif // if defined(__linux__) || defined(__APPLE__)
#define QT_DOMAIN "qt" #define QT_DOMAIN "qt"
...@@ -103,19 +104,19 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri ...@@ -103,19 +104,19 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
BctbxLogLevel level; BctbxLogLevel level;
if (type == QtDebugMsg) { if (type == QtDebugMsg) {
format = GREEN "[%s][Debug]" PURPLE "%s" RESET "%s\n"; format = GREEN "[%s][%p][Debug]" PURPLE "%s" RESET "%s\n";
level = BCTBX_LOG_DEBUG; level = BCTBX_LOG_DEBUG;
} else if (type == QtInfoMsg) { } else if (type == QtInfoMsg) {
format = BLUE "[%s][Info]" PURPLE "%s" RESET "%s\n"; format = BLUE "[%s][%p][Info]" PURPLE "%s" RESET "%s\n";
level = BCTBX_LOG_MESSAGE; level = BCTBX_LOG_MESSAGE;
} else if (type == QtWarningMsg) { } else if (type == QtWarningMsg) {
format = RED "[%s][Warning]" PURPLE "%s" RESET "%s\n"; format = RED "[%s][%p][Warning]" PURPLE "%s" RESET "%s\n";
level = BCTBX_LOG_WARNING; level = BCTBX_LOG_WARNING;
} else if (type == QtCriticalMsg) { } else if (type == QtCriticalMsg) {
format = RED "[%s][Critical]" PURPLE "%s" RESET "%s\n"; format = RED "[%s][%p][Critical]" PURPLE "%s" RESET "%s\n";
level = BCTBX_LOG_ERROR; level = BCTBX_LOG_ERROR;
} else if (type == QtFatalMsg) { } else if (type == QtFatalMsg) {
format = RED "[%s][Fatal]" PURPLE "%s" RESET "%s\n"; format = RED "[%s][%p][Fatal]" PURPLE "%s" RESET "%s\n";
level = BCTBX_LOG_FATAL; level = BCTBX_LOG_FATAL;
} else } else
return; return;
...@@ -144,7 +145,7 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri ...@@ -144,7 +145,7 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
mMutex.lock(); mMutex.lock();
fprintf(stderr, format, dateTime.constData(), context_str, localMsg.constData()); fprintf(stderr, format, dateTime.constData(), QThread::currentThread(), context_str, localMsg.constData());
bctbx_log(QT_DOMAIN, level, "QT: %s%s", context_str, localMsg.constData()); bctbx_log(QT_DOMAIN, level, "QT: %s%s", context_str, localMsg.constData());
mMutex.unlock(); mMutex.unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment