mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 15:25:34 +08:00
refs #865, make log directory available for blackmisc
This commit is contained in:
committed by
Mathew Sutcliffe
parent
68dccbefa6
commit
301db27945
@@ -639,11 +639,7 @@ namespace BlackCore
|
||||
CLogHandler::instance()->install(); // make sure we have a log handler!
|
||||
|
||||
// File logger
|
||||
static const QString logPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
|
||||
"/org.swift-project/" +
|
||||
CDirectoryUtils::normalizedApplicationDirectory() +
|
||||
"/logs";
|
||||
this->m_fileLogger.reset(new CFileLogger(executable(), logPath));
|
||||
this->m_fileLogger.reset(new CFileLogger(executable(), CDirectoryUtils::getLogDirectory()));
|
||||
this->m_fileLogger->changeLogPattern(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityDebug));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/registermetadata.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/logcategory.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
@@ -372,6 +373,17 @@ namespace BlackGui
|
||||
this->displayTextInConsole(files.join("\n"));
|
||||
});
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
|
||||
a = menu.addAction(CIcons::disk16(), "Log directory");
|
||||
c = connect(a, &QAction::triggered, this, [this]()
|
||||
{
|
||||
const QString path(QDir::toNativeSeparators(CDirectoryUtils::getLogDirectory()));
|
||||
if (QDir(path).exists())
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl("file:///" + path));
|
||||
}
|
||||
});
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
}
|
||||
|
||||
void CGuiApplication::addMenuForStyleSheets(QMenu &menu)
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
QString applicationDirectoryPathImpl()
|
||||
{
|
||||
QString appDirectoryString(qApp->applicationDirPath());
|
||||
@@ -49,6 +49,15 @@ namespace BlackMisc
|
||||
return appDir;
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::getLogDirectory()
|
||||
{
|
||||
static const QString logPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
|
||||
"/org.swift-project/" +
|
||||
CDirectoryUtils::normalizedApplicationDirectory() +
|
||||
"/logs";
|
||||
return logPath;
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
//! \endcond
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define BLACKMISC_DIRECTORYUTILS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -32,8 +31,11 @@ namespace BlackMisc
|
||||
//! \note There is no trailing '/'.
|
||||
//! \warning The normalization rules are implementation specific and could change over time.
|
||||
static const QString &normalizedApplicationDirectory();
|
||||
};
|
||||
|
||||
//! Directory for log files
|
||||
//! \remark In BlackMisc so it can also be used from BlackMisc classes
|
||||
static const QString &getLogDirectory();
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user