Commit 99f1a0e2 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): add own linphone logger for qml and c++ files

parent 691a8210
......@@ -13,6 +13,30 @@
// ===================================================================
void qmlLogger (QtMsgType type, const QMessageLogContext &context, const QString &msg) {
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "[Debug]%s:%u: %s\n", context.file, context.line, localMsg.constData());
break;
case QtInfoMsg:
fprintf(stderr, "[Info]%s:%u: %s\n", context.file, context.line, localMsg.constData());
break;
case QtWarningMsg:
fprintf(stderr, "[Warning]%s:%u: %s\n", context.file, context.line, localMsg.constData());
break;
case QtCriticalMsg:
fprintf(stderr, "[Critical]%s:%u: %s\n", context.file, context.line, localMsg.constData());
break;
case QtFatalMsg:
fprintf(stderr, "[Fatal]%s:%u: %s\n", context.file, context.line, localMsg.constData());
abort();
}
}
// ===================================================================
void setTrayIcon (QQmlApplicationEngine &engine) {
QQuickWindow *root = qobject_cast<QQuickWindow *>(engine.rootObjects().at(0));
QMenu *menu = new QMenu();
......@@ -68,7 +92,11 @@ void addContextProperties (QQmlApplicationEngine &engine) {
}
}
// ===================================================================
int main (int argc, char *argv[]) {
qInstallMessageHandler(qmlLogger);
registerTypes();
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
......
......@@ -55,7 +55,7 @@ Item {
}
function _computeHeight () {
console.exception('Virtual method must be implemented.')
throw new Error('Virtual method must be implemented.')
}
// -----------------------------------------------------------------
......
......@@ -2,6 +2,7 @@ import QtQuick 2.7
import QtQuick.Controls 2.0
import Common.Styles 1.0
import Utils 1.0
// ===================================================================
// A reusable search input which display a entries model in a menu.
......@@ -45,7 +46,7 @@ Item {
}
function _filter (text) {
console.assert(
Utils.assert(
model.setFilterFixedString != null,
'`model.setFilterFixedString` must be defined.'
)
......
......@@ -106,6 +106,15 @@ function clearTimeout (timer) {
// -------------------------------------------------------------------
// Basic assert function.
function assert (condition, message) {
if (!condition) {
throw new Error('Assert: ' + message)
}
}
// -------------------------------------------------------------------
// Returns the top (root) parent of one object.
function getTopParent (object, useFakeParent) {
function _getTopParent (object, useFakeParent) {
......
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