mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
Write App log in output directly from Qt handler instead of waiting for Linphone thread. This avoid having log latency in output or hidden log at startup.
This commit is contained in:
parent
978c57f1ed
commit
64c738047d
5 changed files with 54 additions and 11 deletions
|
|
@ -19,6 +19,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "QtLogger.hpp"
|
#include "QtLogger.hpp"
|
||||||
|
#include "model/core/CoreModel.hpp"
|
||||||
|
#include "tool/LinphoneEnums.hpp"
|
||||||
#include "tool/Utils.hpp"
|
#include "tool/Utils.hpp"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
@ -66,15 +68,16 @@ QtLogger *QtLogger::getInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtLogger::onQtLog(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
void QtLogger::onQtLog(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||||
if (type == QtFatalMsg) {
|
QString out;
|
||||||
QString out; // Qt force call abort() that kill the application. So it cannot be used to retrieve
|
if (gLogger.mVerboseEnabled) {
|
||||||
// in other thread. Print the error in the hope that it can be catch somewhere.
|
gLogger.printLog(&out, Constants::AppDomain, LinphoneEnums::toLinphone(type),
|
||||||
gLogger.printLog(&out, Constants::AppDomain, linphone::LogLevel::Fatal, Utils::appStringToCoreString(msg));
|
Utils::appStringToCoreString(msg));
|
||||||
}
|
}
|
||||||
emit gLogger.qtLogReceived(type, context.file, context.line, msg);
|
emit gLogger.qtLogReceived(type, context.file, context.line, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtLogger::enableVerbose(bool verbose) {
|
void QtLogger::enableVerbose(bool verbose) {
|
||||||
|
gLogger.mVerboseEnabled = verbose;
|
||||||
emit gLogger.requestVerboseEnabled(verbose);
|
emit gLogger.requestVerboseEnabled(verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
//
|
//
|
||||||
// Qt SDK
|
// Qt SDK
|
||||||
//fatal | |
|
// fatal | |
|
||||||
// -- *----------> |
|
// -- *----------> |
|
||||||
// | |
|
// | |
|
||||||
// | | <--------- *
|
// | | <--------- *
|
||||||
|
|
@ -47,13 +47,13 @@ public:
|
||||||
static QtLogger *getInstance();
|
static QtLogger *getInstance();
|
||||||
static void enableVerbose(bool verbose);
|
static void enableVerbose(bool verbose);
|
||||||
static void enableQtOnly(bool qtOnly);
|
static void enableQtOnly(bool qtOnly);
|
||||||
|
|
||||||
void printLog(QString * qMessage, const std::string &domain, linphone::LogLevel level, const std::string &message);
|
void printLog(QString *qMessage, const std::string &domain, linphone::LogLevel level, const std::string &message);
|
||||||
|
|
||||||
// Log Sources
|
// Log Sources
|
||||||
static void onQtLog(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
static void onQtLog(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||||
void onLinphoneLog(const std::string &domain, linphone::LogLevel level, const std::string &message);
|
void onLinphoneLog(const std::string &domain, linphone::LogLevel level, const std::string &message);
|
||||||
|
bool mVerboseEnabled = false;
|
||||||
signals:
|
signals:
|
||||||
void qtLogReceived(QtMsgType type, QString contextFile, int contextLine, QString msg);
|
void qtLogReceived(QtMsgType type, QString contextFile, int contextLine, QString msg);
|
||||||
void requestVerboseEnabled(bool verbose);
|
void requestVerboseEnabled(bool verbose);
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,8 @@ void LoggerModel::onLinphoneLog(const std::shared_ptr<linphone::LoggingService>
|
||||||
linphone::LogLevel level,
|
linphone::LogLevel level,
|
||||||
const std::string &message) {
|
const std::string &message) {
|
||||||
bool isAppLog = domain == Constants::AppDomain;
|
bool isAppLog = domain == Constants::AppDomain;
|
||||||
if (!mVerboseEnabled || (!isAppLog && mQtOnlyEnabled)) return;
|
if (isAppLog || !mVerboseEnabled || mQtOnlyEnabled) return; // App logs are already managed.
|
||||||
|
|
||||||
emit linphoneLogReceived(domain, level, message);
|
emit linphoneLogReceived(domain, level, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,42 @@ LinphoneEnums::ConferenceSchedulerState LinphoneEnums::fromLinphone(const linpho
|
||||||
return static_cast<LinphoneEnums::ConferenceSchedulerState>(state);
|
return static_cast<LinphoneEnums::ConferenceSchedulerState>(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linphone::LogLevel LinphoneEnums::toLinphone(const QtMsgType &data) {
|
||||||
|
switch (data) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
return linphone::LogLevel::Debug;
|
||||||
|
case QtWarningMsg:
|
||||||
|
return linphone::LogLevel::Warning;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
return linphone::LogLevel::Error;
|
||||||
|
case QtFatalMsg:
|
||||||
|
return linphone::LogLevel::Fatal;
|
||||||
|
case QtInfoMsg:
|
||||||
|
return linphone::LogLevel::Message;
|
||||||
|
default:
|
||||||
|
return linphone::LogLevel::Trace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMsgType LinphoneEnums::fromLinphone(const linphone::LogLevel &data) {
|
||||||
|
switch (data) {
|
||||||
|
case linphone::LogLevel::Debug:
|
||||||
|
return QtDebugMsg;
|
||||||
|
case linphone::LogLevel::Trace:
|
||||||
|
return QtInfoMsg;
|
||||||
|
case linphone::LogLevel::Message:
|
||||||
|
return QtInfoMsg;
|
||||||
|
case linphone::LogLevel::Warning:
|
||||||
|
return QtWarningMsg;
|
||||||
|
case linphone::LogLevel::Error:
|
||||||
|
return QtCriticalMsg;
|
||||||
|
case linphone::LogLevel::Fatal:
|
||||||
|
return QtFatalMsg;
|
||||||
|
default:
|
||||||
|
return QtInfoMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
linphone::ParticipantDevice::State LinphoneEnums::toLinphone(const LinphoneEnums::ParticipantDeviceState &state) {
|
linphone::ParticipantDevice::State LinphoneEnums::toLinphone(const LinphoneEnums::ParticipantDeviceState &state) {
|
||||||
return static_cast<linphone::ParticipantDevice::State>(state);
|
return static_cast<linphone::ParticipantDevice::State>(state);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,9 @@ Q_ENUM_NS(ConferenceSchedulerState)
|
||||||
linphone::ConferenceScheduler::State toLinphone(const LinphoneEnums::ConferenceSchedulerState &state);
|
linphone::ConferenceScheduler::State toLinphone(const LinphoneEnums::ConferenceSchedulerState &state);
|
||||||
LinphoneEnums::ConferenceSchedulerState fromLinphone(const linphone::ConferenceScheduler::State &state);
|
LinphoneEnums::ConferenceSchedulerState fromLinphone(const linphone::ConferenceScheduler::State &state);
|
||||||
|
|
||||||
|
linphone::LogLevel toLinphone(const QtMsgType &data);
|
||||||
|
QtMsgType fromLinphone(const linphone::LogLevel &data);
|
||||||
|
|
||||||
enum class ParticipantDeviceState {
|
enum class ParticipantDeviceState {
|
||||||
Joining = int(linphone::ParticipantDevice::State::Joining),
|
Joining = int(linphone::ParticipantDevice::State::Joining),
|
||||||
Present = int(linphone::ParticipantDevice::State::Present),
|
Present = int(linphone::ParticipantDevice::State::Present),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue