Fix path to logs on Windows.
This commit is contained in:
parent
7378cfbe95
commit
08c4d1e411
|
@ -39,6 +39,30 @@
|
||||||
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
auto LogDirPath(const QString &appName) -> QString
|
||||||
|
{
|
||||||
|
const QString logs = QStringLiteral("Logs");
|
||||||
|
|
||||||
|
QString logDirPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||||
|
if (logDirPath.isEmpty())
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_WINDOWS)
|
||||||
|
return QStringList{QCoreApplication::applicationDirPath(), logs, appName}.join(QDir::separator());
|
||||||
|
#else
|
||||||
|
return QStringList{QDir::homePath(), VER_COMPANYNAME_STR, logs, appName}.join(QDir::separator());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if defined(Q_OS_WINDOWS)
|
||||||
|
QString path = QStringList{logDirPath, logs}.join(QDir::separator());
|
||||||
|
#else
|
||||||
|
QString path = QStringList{logDirPath, VER_COMPANYNAME_STR, logs, appName}.join(QDir::separator());
|
||||||
|
#endif
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VCrashPaths::VCrashPaths(QString exeDir)
|
VCrashPaths::VCrashPaths(QString exeDir)
|
||||||
: m_exeDir(std::move(exeDir))
|
: m_exeDir(std::move(exeDir))
|
||||||
|
@ -48,19 +72,9 @@ VCrashPaths::VCrashPaths(QString exeDir)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VCrashPaths::GetAttachmentPath(const QString &appName) -> QString
|
auto VCrashPaths::GetAttachmentPath(const QString &appName) -> QString
|
||||||
{
|
{
|
||||||
QString logDirPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
return QStringLiteral("%1/%2-pid%3.log")
|
||||||
if (logDirPath.isEmpty())
|
.arg(LogDirPath(appName), appName.toLower())
|
||||||
{
|
.arg(QCoreApplication::applicationPid());
|
||||||
QString const logDirName = VER_COMPANYNAME_STR + "Logs"_L1;
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
|
||||||
logDirPath =
|
|
||||||
QDir::homePath() + QDir::separator() + logDirName + QDir::separator() + QCoreApplication::applicationName();
|
|
||||||
#else
|
|
||||||
logDirPath = QCoreApplication::applicationDirPath() + QDir::separator() + logDirName + QDir::separator() +
|
|
||||||
QCoreApplication::applicationName();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return QStringLiteral("%1/%2-pid%3.log").arg(logDirPath, appName.toLower()).arg(QCoreApplication::applicationPid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -649,19 +649,28 @@ void VAbstractApplication::InitHighDpiScaling(int argc, char *argv[])
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VAbstractApplication::LogDirPath() -> QString
|
auto VAbstractApplication::LogDirPath() -> QString
|
||||||
{
|
{
|
||||||
QString logDirPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
const QString logs = QStringLiteral("Logs");
|
||||||
|
|
||||||
|
QString const logDirPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||||
if (logDirPath.isEmpty())
|
if (logDirPath.isEmpty())
|
||||||
{
|
{
|
||||||
QString const logDirName = QCoreApplication::organizationName() + "Logs"_L1;
|
#if defined(Q_OS_WINDOWS)
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
return QStringList{QCoreApplication::applicationDirPath(), logs, QCoreApplication::applicationName()}.join(
|
||||||
logDirPath =
|
QDir::separator());
|
||||||
QDir::homePath() + QDir::separator() + logDirName + QDir::separator() + QCoreApplication::applicationName();
|
|
||||||
#else
|
#else
|
||||||
logDirPath = QCoreApplication::applicationDirPath() + QDir::separator() + logDirName + QDir::separator() +
|
return QStringList{QDir::homePath(), QCoreApplication::organizationName(), logs,
|
||||||
QCoreApplication::applicationName();
|
QCoreApplication::applicationName()}
|
||||||
|
.join(QDir::separator());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return logDirPath;
|
#if defined(Q_OS_WINDOWS)
|
||||||
|
QString path = QStringList{logDirPath, logs}.join(QDir::separator());
|
||||||
|
#else
|
||||||
|
QString path =
|
||||||
|
QStringList{logDirPath, QCoreApplication::organizationName(), logs, QCoreApplication::applicationName()}.join(
|
||||||
|
QDir::separator());
|
||||||
|
#endif
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user