mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
Merge pull request #3141
3c28ece
Logger: runtime log config, no logs till a user selects wallet mode (xiphon)
This commit is contained in:
commit
8c5891e28a
8 changed files with 74 additions and 25 deletions
1
main.qml
1
main.qml
|
@ -1367,6 +1367,7 @@ ApplicationWindow {
|
||||||
} else {
|
} else {
|
||||||
wizard.wizardState = "wizardHome";
|
wizard.wizardState = "wizardHome";
|
||||||
rootItem.state = "normal"
|
rootItem.state = "normal"
|
||||||
|
logger.resetLogFilePath(persistentSettings.portable);
|
||||||
openWallet("wizard");
|
openWallet("wizard");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,9 +272,9 @@ Rectangle {
|
||||||
<style type='text/css'>\
|
<style type='text/css'>\
|
||||||
a {cursor:pointer;text-decoration: none; color: #FF6C3C}\
|
a {cursor:pointer;text-decoration: none; color: #FF6C3C}\
|
||||||
</style>\
|
</style>\
|
||||||
<a href='#'>%1</a>".arg(walletLogPath)
|
<a href='#'>%1</a>".arg(logger.logFilePath)
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
onLinkActivated: oshelper.openContainingFolder(walletLogPath)
|
onLinkActivated: oshelper.openContainingFolder(logger.logFilePath)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -397,7 +397,7 @@ Rectangle {
|
||||||
if(currentWallet)
|
if(currentWallet)
|
||||||
data += currentWallet.walletCreationHeight;
|
data += currentWallet.walletCreationHeight;
|
||||||
|
|
||||||
data += "\nWallet log path: " + walletLogPath;
|
data += "\nWallet log path: " + logger.logFilePath;
|
||||||
data += "\nWallet mode: " + walletModeString;
|
data += "\nWallet mode: " + walletModeString;
|
||||||
data += "\nGraphics mode: " + isOpenGL ? "OpenGL" : "Low graphics mode";
|
data += "\nGraphics mode: " + isOpenGL ? "OpenGL" : "Low graphics mode";
|
||||||
if (isTails)
|
if (isTails)
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -33,9 +35,11 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "Logger.h"
|
#include <easylogging++.h>
|
||||||
|
#include <wallet/api/wallet2_api.h>
|
||||||
|
|
||||||
|
#include "qt/MoneroSettings.h"
|
||||||
#include "qt/TailsOS.h"
|
#include "qt/TailsOS.h"
|
||||||
#include "wallet/api/wallet2_api.h"
|
|
||||||
|
|
||||||
// default log path by OS (should be writable)
|
// default log path by OS (should be writable)
|
||||||
static const QString defaultLogName = "monero-wallet-gui.log";
|
static const QString defaultLogName = "monero-wallet-gui.log";
|
||||||
|
@ -63,15 +67,21 @@ static const QString defaultLogName = "monero-wallet-gui.log";
|
||||||
|
|
||||||
|
|
||||||
// return the absolute path of the logfile and ensure path folder exists
|
// return the absolute path of the logfile and ensure path folder exists
|
||||||
const QString getLogPath(const QString logPath)
|
const QString getLogPath(const QString &userDefinedLogFilePath, bool portable)
|
||||||
{
|
{
|
||||||
const QFileInfo fi(logPath);
|
const QFileInfo fi(userDefinedLogFilePath);
|
||||||
|
if (!userDefinedLogFilePath.isEmpty() && !fi.isDir())
|
||||||
|
{
|
||||||
|
return fi.absoluteFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (portable)
|
||||||
|
{
|
||||||
|
return QDir(MoneroSettings::portableFolderName()).filePath(defaultLogName);
|
||||||
|
}
|
||||||
|
|
||||||
if(TailsOS::detect() && TailsOS::usePersistence)
|
if(TailsOS::detect() && TailsOS::usePersistence)
|
||||||
return QDir::homePath() + "/Persistent/Monero/logs/" + defaultLogName;
|
return QDir::homePath() + "/Persistent/Monero/logs/" + defaultLogName;
|
||||||
|
|
||||||
if(!logPath.isEmpty() && !fi.isDir())
|
|
||||||
return fi.absoluteFilePath();
|
|
||||||
else {
|
else {
|
||||||
QDir appDir(osPath + "/" + appFolder);
|
QDir appDir(osPath + "/" + appFolder);
|
||||||
if(!appDir.exists())
|
if(!appDir.exists())
|
||||||
|
@ -98,3 +108,26 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::Logger(QCoreApplication &parent, QString userDefinedLogFilePath)
|
||||||
|
: QObject(&parent)
|
||||||
|
, m_applicationFilePath(parent.applicationFilePath().toStdString())
|
||||||
|
, m_userDefinedLogFilePath(std::move(userDefinedLogFilePath))
|
||||||
|
{
|
||||||
|
el::Configurations c;
|
||||||
|
c.setGlobally(el::ConfigurationType::ToFile, "false");
|
||||||
|
c.setGlobally(el::ConfigurationType::ToStandardOutput, "true");
|
||||||
|
el::Loggers::setDefaultConfigurations(c, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger::resetLogFilePath(bool portable)
|
||||||
|
{
|
||||||
|
m_logFilePath = QDir::toNativeSeparators(getLogPath(m_userDefinedLogFilePath, portable));
|
||||||
|
Monero::Wallet::init(m_applicationFilePath.c_str(), "monero-wallet-gui", m_logFilePath.toStdString(), true);
|
||||||
|
qInstallMessageHandler(messageHandler);
|
||||||
|
emit logFilePathChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Logger::logFilePath() const
|
||||||
|
{
|
||||||
|
return m_logFilePath;
|
||||||
|
}
|
||||||
|
|
|
@ -26,11 +26,28 @@
|
||||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef LOGGER_H
|
#pragma once
|
||||||
#define LOGGER_H
|
|
||||||
|
|
||||||
const QString getLogPath(const QString logPath);
|
#include <QCoreApplication>
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#endif // LOGGER_H
|
class Logger : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString logFilePath READ logFilePath NOTIFY logFilePathChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
Logger(QCoreApplication &parent, QString userDefinedLogFilePath);
|
||||||
|
|
||||||
|
Q_INVOKABLE void resetLogFilePath(bool portable);
|
||||||
|
QString logFilePath() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void logFilePathChanged() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string m_applicationFilePath;
|
||||||
|
QString m_logFilePath;
|
||||||
|
const QString m_userDefinedLogFilePath;
|
||||||
|
};
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#include "model/SubaddressModel.h"
|
#include "model/SubaddressModel.h"
|
||||||
#include "SubaddressAccount.h"
|
#include "SubaddressAccount.h"
|
||||||
#include "model/SubaddressAccountModel.h"
|
#include "model/SubaddressAccountModel.h"
|
||||||
#include "wallet/api/wallet2_api.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "MainApp.h"
|
#include "MainApp.h"
|
||||||
#include "qt/downloader.h"
|
#include "qt/downloader.h"
|
||||||
|
@ -269,10 +268,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
|
|
||||||
Monero::Utils::onStartup();
|
Monero::Utils::onStartup();
|
||||||
|
|
||||||
// Log settings
|
Logger logger(app, parser.value(logPathOption));
|
||||||
const QString logPath = QDir::toNativeSeparators(getLogPath(parser.value(logPathOption)));
|
|
||||||
Monero::Wallet::init(argv[0], "monero-wallet-gui", logPath.toStdString().c_str(), true);
|
|
||||||
qInstallMessageHandler(messageHandler);
|
|
||||||
|
|
||||||
// loglevel is configured in main.qml. Anything lower than
|
// loglevel is configured in main.qml. Anything lower than
|
||||||
// qWarning is not shown here unless MONERO_LOG_LEVEL env var is set
|
// qWarning is not shown here unless MONERO_LOG_LEVEL env var is set
|
||||||
|
@ -281,7 +277,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
if (logLevelOk && logLevel >= 0 && logLevel <= Monero::WalletManagerFactory::LogLevel_Max){
|
if (logLevelOk && logLevel >= 0 && logLevel <= Monero::WalletManagerFactory::LogLevel_Max){
|
||||||
Monero::WalletManagerFactory::setLogLevel(logLevel);
|
Monero::WalletManagerFactory::setLogLevel(logLevel);
|
||||||
}
|
}
|
||||||
qWarning().noquote() << "app startd" << "(log: " + logPath + ")";
|
qWarning().noquote() << "app startd" << "(log: " + logger.logFilePath() + ")";
|
||||||
|
|
||||||
if (parser.isSet(verifyUpdateOption))
|
if (parser.isSet(verifyUpdateOption))
|
||||||
{
|
{
|
||||||
|
@ -446,14 +442,14 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
|
|
||||||
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
||||||
|
|
||||||
|
engine.rootContext()->setContextProperty("logger", &logger);
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("mainApp", &app);
|
engine.rootContext()->setContextProperty("mainApp", &app);
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("IPC", ipc);
|
engine.rootContext()->setContextProperty("IPC", ipc);
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("qtRuntimeVersion", qVersion());
|
engine.rootContext()->setContextProperty("qtRuntimeVersion", qVersion());
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("walletLogPath", logPath);
|
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("tailsUsePersistence", TailsOS::usePersistence);
|
engine.rootContext()->setContextProperty("tailsUsePersistence", TailsOS::usePersistence);
|
||||||
|
|
||||||
// Exclude daemon manager from IOS
|
// Exclude daemon manager from IOS
|
||||||
|
|
|
@ -191,7 +191,7 @@ QString MoneroSettings::portableFilePath() const
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MoneroSettings::portableFolderName() const
|
QString MoneroSettings::portableFolderName()
|
||||||
{
|
{
|
||||||
return "monero-storage";
|
return "monero-storage";
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@ public:
|
||||||
Q_INVOKABLE bool setPortable(bool enabled);
|
Q_INVOKABLE bool setPortable(bool enabled);
|
||||||
Q_INVOKABLE void setWritable(bool enabled);
|
Q_INVOKABLE void setWritable(bool enabled);
|
||||||
|
|
||||||
|
static QString portableFolderName();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void _q_propertyChanged();
|
void _q_propertyChanged();
|
||||||
|
|
||||||
|
@ -84,7 +86,6 @@ private:
|
||||||
bool portable() const;
|
bool portable() const;
|
||||||
bool portableConfigExists() const;
|
bool portableConfigExists() const;
|
||||||
QString portableFilePath() const;
|
QString portableFilePath() const;
|
||||||
QString portableFolderName() const;
|
|
||||||
std::unique_ptr<QSettings> portableSettings() const;
|
std::unique_ptr<QSettings> portableSettings() const;
|
||||||
std::unique_ptr<QSettings> unportableSettings() const;
|
std::unique_ptr<QSettings> unportableSettings() const;
|
||||||
void swap(std::unique_ptr<QSettings> newSettings);
|
void swap(std::unique_ptr<QSettings> newSettings);
|
||||||
|
|
|
@ -48,6 +48,7 @@ Rectangle {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.resetLogFilePath(portable);
|
||||||
appWindow.changeWalletMode(mode);
|
appWindow.changeWalletMode(mode);
|
||||||
wizardController.wizardStackView.backTransition = false;
|
wizardController.wizardStackView.backTransition = false;
|
||||||
wizardController.wizardState = wizardState;
|
wizardController.wizardState = wizardState;
|
||||||
|
|
Loading…
Reference in a new issue