modify:修改linux下的日志目录
This commit is contained in:
@@ -78,6 +78,25 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString LinuxRuntimeRoot()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QByteArray root = qgetenv("LC_APP_ROOT");
|
||||||
|
if(!root.isEmpty())
|
||||||
|
{
|
||||||
|
return QDir::cleanPath(QString::fromLocal8Bit(root));
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray appImage = qgetenv("APPIMAGE");
|
||||||
|
if(!appImage.isEmpty())
|
||||||
|
{
|
||||||
|
return QFileInfo(QString::fromLocal8Bit(appImage)).absolutePath();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return QCoreApplication::applicationDirPath();
|
||||||
|
}
|
||||||
|
|
||||||
// 给Qt安装消息处理函数
|
// 给Qt安装消息处理函数
|
||||||
void LogHandler::installMessageHandler()
|
void LogHandler::installMessageHandler()
|
||||||
{
|
{
|
||||||
@@ -89,7 +108,12 @@ void LogHandler::installMessageHandler()
|
|||||||
auto _currentDate = QDateTime::currentDateTime().toString("yyyy-MM-dd");
|
auto _currentDate = QDateTime::currentDateTime().toString("yyyy-MM-dd");
|
||||||
|
|
||||||
//打开/创建文件
|
//打开/创建文件
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
auto _appDirPath = LinuxRuntimeRoot();
|
||||||
|
#else
|
||||||
auto _appDirPath = QCoreApplication::applicationDirPath();
|
auto _appDirPath = QCoreApplication::applicationDirPath();
|
||||||
|
#endif
|
||||||
|
|
||||||
auto _logDirPath = _appDirPath + "/logs/";
|
auto _logDirPath = _appDirPath + "/logs/";
|
||||||
QDir _logDir(_logDirPath);
|
QDir _logDir(_logDirPath);
|
||||||
if(!_logDir.exists())
|
if(!_logDir.exists())
|
||||||
|
|||||||
Reference in New Issue
Block a user