mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
Merge pull request #1358
341ac18
log qt/qml to easylogging, add --log-file cmdline option92582a9
delete unused WalletManager functionsc9daab7
don't use cmdline arguments as daemon arguments7283fe4
use qWarning/qCritical on QrCodeScanner info/errors15155f2
print logs on console
This commit is contained in:
commit
4c2640d4b3
9 changed files with 78 additions and 51 deletions
49
Logger.cpp
Normal file
49
Logger.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
#include "wallet/api/wallet2_api.h"
|
||||||
|
|
||||||
|
// default log path by OS (should be writable)
|
||||||
|
static const QString default_name = "monero-wallet-gui.log";
|
||||||
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||||
|
static const QString osPath = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).at(0);
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
static const QString osPath = QCoreApplication::applicationDirPath();
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
static const QString osPath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0) + "/Library/Logs";
|
||||||
|
#else // linux + bsd
|
||||||
|
static const QString osPath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// return the absolute path of the logfile
|
||||||
|
const QString getLogPath(const QString logPath)
|
||||||
|
{
|
||||||
|
const QFileInfo fi(logPath);
|
||||||
|
|
||||||
|
if(!logPath.isEmpty() && !fi.isDir())
|
||||||
|
return fi.absoluteFilePath();
|
||||||
|
else
|
||||||
|
return osPath + "/" + default_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// custom messageHandler that foward all messages to easylogging
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||||
|
{
|
||||||
|
(void) context; // context isn't used in release builds
|
||||||
|
const std::string cat = "frontend"; // category displayed in the log
|
||||||
|
const std::string msg = message.toStdString();
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case QtDebugMsg: Monero::Wallet::debug(cat, msg); break;
|
||||||
|
case QtInfoMsg: Monero::Wallet::info(cat, msg); break;
|
||||||
|
case QtWarningMsg: Monero::Wallet::warning(cat, msg); break;
|
||||||
|
case QtCriticalMsg: Monero::Wallet::error(cat, msg); break;
|
||||||
|
case QtFatalMsg: Monero::Wallet::error(cat, msg); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
8
Logger.h
Normal file
8
Logger.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef LOGGER_H
|
||||||
|
#define LOGGER_H
|
||||||
|
|
||||||
|
const QString getLogPath(const QString logPath);
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
||||||
|
|
||||||
|
#endif // LOGGER_H
|
||||||
|
|
29
main.cpp
29
main.cpp
|
@ -54,6 +54,7 @@
|
||||||
#include "Subaddress.h"
|
#include "Subaddress.h"
|
||||||
#include "model/SubaddressModel.h"
|
#include "model/SubaddressModel.h"
|
||||||
#include "wallet/api/wallet2_api.h"
|
#include "wallet/api/wallet2_api.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "MainApp.h"
|
#include "MainApp.h"
|
||||||
|
|
||||||
// IOS exclusions
|
// IOS exclusions
|
||||||
|
@ -70,12 +71,6 @@ bool isAndroid = false;
|
||||||
bool isWindows = false;
|
bool isWindows = false;
|
||||||
bool isDesktop = 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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// platform dependant settings
|
// platform dependant settings
|
||||||
|
@ -117,16 +112,24 @@ int main(int argc, char *argv[])
|
||||||
app.installEventFilter(eventFilter);
|
app.installEventFilter(eventFilter);
|
||||||
|
|
||||||
QCommandLineParser parser;
|
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.addHelpOption();
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
|
|
||||||
Monero::Utils::onStartup();
|
Monero::Utils::onStartup();
|
||||||
|
|
||||||
// Log settings
|
// Log settings
|
||||||
Monero::Wallet::init(argv[0], "monero-wallet-gui");
|
const QString logPath = getLogPath(parser.value(logPathOption));
|
||||||
// qInstallMessageHandler(messageHandler);
|
Monero::Wallet::init(argv[0], "monero-wallet-gui", logPath.toStdString().c_str(), true);
|
||||||
|
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
|
// screen settings
|
||||||
// Mobile is designed on 128dpi
|
// Mobile is designed on 128dpi
|
||||||
|
@ -217,9 +220,11 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("qtRuntimeVersion", qVersion());
|
engine.rootContext()->setContextProperty("qtRuntimeVersion", qVersion());
|
||||||
|
|
||||||
|
engine.rootContext()->setContextProperty("walletLogPath", logPath);
|
||||||
|
|
||||||
// Exclude daemon manager from IOS
|
// Exclude daemon manager from IOS
|
||||||
#ifndef Q_OS_IOS
|
#ifndef Q_OS_IOS
|
||||||
const QStringList arguments = QCoreApplication::arguments();
|
const QStringList arguments = (QStringList) QCoreApplication::arguments().at(0);
|
||||||
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
||||||
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
|
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
|
||||||
#endif
|
#endif
|
||||||
|
@ -289,13 +294,13 @@ int main(int argc, char *argv[])
|
||||||
QObject *qmlCamera = rootObject->findChild<QObject*>("qrCameraQML");
|
QObject *qmlCamera = rootObject->findChild<QObject*>("qrCameraQML");
|
||||||
if (qmlCamera)
|
if (qmlCamera)
|
||||||
{
|
{
|
||||||
qDebug() << "QrCodeScanner : object found";
|
qWarning() << "QrCodeScanner : object found";
|
||||||
QCamera *camera_ = qvariant_cast<QCamera*>(qmlCamera->property("mediaObject"));
|
QCamera *camera_ = qvariant_cast<QCamera*>(qmlCamera->property("mediaObject"));
|
||||||
QObject *qmlFinder = rootObject->findChild<QObject*>("QrFinder");
|
QObject *qmlFinder = rootObject->findChild<QObject*>("QrFinder");
|
||||||
qobject_cast<QrCodeScanner*>(qmlFinder)->setSource(camera_);
|
qobject_cast<QrCodeScanner*>(qmlFinder)->setSource(camera_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qDebug() << "QrCodeScanner : something went wrong !";
|
qCritical() << "QrCodeScanner : something went wrong !";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QObject::connect(eventFilter, SIGNAL(sequencePressed(QVariant,QVariant)), rootObject, SLOT(sequencePressed(QVariant,QVariant)));
|
QObject::connect(eventFilter, SIGNAL(sequencePressed(QVariant,QVariant)), rootObject, SLOT(sequencePressed(QVariant,QVariant)));
|
||||||
|
|
|
@ -45,6 +45,7 @@ HEADERS += \
|
||||||
src/libwalletqt/Subaddress.h \
|
src/libwalletqt/Subaddress.h \
|
||||||
src/zxcvbn-c/zxcvbn.h \
|
src/zxcvbn-c/zxcvbn.h \
|
||||||
src/libwalletqt/UnsignedTransaction.h \
|
src/libwalletqt/UnsignedTransaction.h \
|
||||||
|
Logger.h \
|
||||||
MainApp.h
|
MainApp.h
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
|
@ -70,6 +71,7 @@ SOURCES += main.cpp \
|
||||||
src/libwalletqt/Subaddress.cpp \
|
src/libwalletqt/Subaddress.cpp \
|
||||||
src/zxcvbn-c/zxcvbn.c \
|
src/zxcvbn-c/zxcvbn.c \
|
||||||
src/libwalletqt/UnsignedTransaction.cpp \
|
src/libwalletqt/UnsignedTransaction.cpp \
|
||||||
|
Logger.cpp \
|
||||||
MainApp.cpp
|
MainApp.cpp
|
||||||
|
|
||||||
CONFIG(DISABLE_PASS_STRENGTH_METER) {
|
CONFIG(DISABLE_PASS_STRENGTH_METER) {
|
||||||
|
|
|
@ -730,13 +730,13 @@ Rectangle {
|
||||||
TextBlock {
|
TextBlock {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
text: (!currentWallet) ? "" : qsTr("Wallet log path: ") + translationManager.emptyString
|
text: qsTr("Wallet log path: ") + translationManager.emptyString
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBlock {
|
TextBlock {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
text: currentWallet.walletLogPath + translationManager.emptyString
|
text: walletLogPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -722,17 +722,6 @@ QString Wallet::getDaemonLogPath() const
|
||||||
return QString::fromStdString(m_walletImpl->getDefaultDataDir()) + "/bitmonero.log";
|
return QString::fromStdString(m_walletImpl->getDefaultDataDir()) + "/bitmonero.log";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Wallet::getWalletLogPath() const
|
|
||||||
{
|
|
||||||
const QString filename("monero-wallet-gui.log");
|
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
return QStandardPaths::standardLocations(QStandardPaths::HomeLocation).at(0) + "/Library/Logs/" + filename;
|
|
||||||
#else
|
|
||||||
return QCoreApplication::applicationDirPath() + "/" + filename;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Wallet::blackballOutput(const QString &pubkey)
|
bool Wallet::blackballOutput(const QString &pubkey)
|
||||||
{
|
{
|
||||||
QList<QString> list;
|
QList<QString> list;
|
||||||
|
|
|
@ -50,7 +50,6 @@ class Wallet : public QObject
|
||||||
Q_PROPERTY(QString secretSpendKey READ getSecretSpendKey)
|
Q_PROPERTY(QString secretSpendKey READ getSecretSpendKey)
|
||||||
Q_PROPERTY(QString publicSpendKey READ getPublicSpendKey)
|
Q_PROPERTY(QString publicSpendKey READ getPublicSpendKey)
|
||||||
Q_PROPERTY(QString daemonLogPath READ getDaemonLogPath CONSTANT)
|
Q_PROPERTY(QString daemonLogPath READ getDaemonLogPath CONSTANT)
|
||||||
Q_PROPERTY(QString walletLogPath READ getWalletLogPath CONSTANT)
|
|
||||||
Q_PROPERTY(quint64 walletCreationHeight READ getWalletCreationHeight WRITE setWalletCreationHeight NOTIFY walletCreationHeightChanged)
|
Q_PROPERTY(quint64 walletCreationHeight READ getWalletCreationHeight WRITE setWalletCreationHeight NOTIFY walletCreationHeightChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -377,26 +377,6 @@ bool WalletManager::clearWalletCache(const QString &wallet_path) const
|
||||||
return walletCache.rename(newFileName);
|
return walletCache.rename(newFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletManager::debug(const QString &s)
|
|
||||||
{
|
|
||||||
Monero::Wallet::debug("qml", s.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletManager::info(const QString &s)
|
|
||||||
{
|
|
||||||
Monero::Wallet::info("qml", s.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletManager::warning(const QString &s)
|
|
||||||
{
|
|
||||||
Monero::Wallet::warning("qml", s.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletManager::error(const QString &s)
|
|
||||||
{
|
|
||||||
Monero::Wallet::error("qml", s.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
WalletManager::WalletManager(QObject *parent) : QObject(parent)
|
WalletManager::WalletManager(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_pimpl = Monero::WalletManagerFactory::getWalletManager();
|
m_pimpl = Monero::WalletManagerFactory::getWalletManager();
|
||||||
|
|
|
@ -143,11 +143,6 @@ public:
|
||||||
// clear/rename wallet cache
|
// clear/rename wallet cache
|
||||||
Q_INVOKABLE bool clearWalletCache(const QString &fileName) const;
|
Q_INVOKABLE bool clearWalletCache(const QString &fileName) const;
|
||||||
|
|
||||||
Q_INVOKABLE void debug(const QString &s);
|
|
||||||
Q_INVOKABLE void info(const QString &s);
|
|
||||||
Q_INVOKABLE void warning(const QString &s);
|
|
||||||
Q_INVOKABLE void error(const QString &s);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void walletOpened(Wallet * wallet);
|
void walletOpened(Wallet * wallet);
|
||||||
|
|
Loading…
Reference in a new issue