log qt/qml to easylogging, add --log-file cmdline option

This commit is contained in:
pazos
2018-05-08 18:13:29 +02:00
parent 7cea134352
commit 341ac18f1a
7 changed files with 75 additions and 23 deletions

View File

@@ -54,6 +54,7 @@
#include "Subaddress.h"
#include "model/SubaddressModel.h"
#include "wallet/api/wallet2_api.h"
#include "Logger.h"
#include "MainApp.h"
// IOS exclusions
@@ -70,12 +71,6 @@ bool isAndroid = false;
bool isWindows = false;
bool isDesktop = false;
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
// Send all message types to logger
Monero::Wallet::debug("qml", msg.toStdString());
}
int main(int argc, char *argv[])
{
// platform dependant settings
@@ -117,16 +112,24 @@ int main(int argc, char *argv[])
app.installEventFilter(eventFilter);
QCommandLineParser parser;
QCommandLineOption logPathOption(QStringList() << "l" << "log-file",
QCoreApplication::translate("main", "Log to specified file"),
QCoreApplication::translate("main", "file"));
parser.addOption(logPathOption);
parser.addHelpOption();
parser.process(app);
Monero::Utils::onStartup();
// Log settings
Monero::Wallet::init(argv[0], "monero-wallet-gui");
// qInstallMessageHandler(messageHandler);
const QString logPath = getLogPath(parser.value(logPathOption));
Monero::Wallet::init(argv[0], "monero-wallet-gui", logPath.toStdString().c_str());
qInstallMessageHandler(messageHandler);
qDebug() << "app startd";
// loglevel is configured in main.qml. Anything lower than
// qWarning is not shown here.
qWarning().noquote() << "app startd" << "(log: " + logPath + ")";
// screen settings
// Mobile is designed on 128dpi
@@ -217,6 +220,8 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("qtRuntimeVersion", qVersion());
engine.rootContext()->setContextProperty("walletLogPath", logPath);
// Exclude daemon manager from IOS
#ifndef Q_OS_IOS
const QStringList arguments = QCoreApplication::arguments();