Commit 2771cd99 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Split the log in sysinfo and session log

parent 465416bd
...@@ -570,11 +570,11 @@ extern "C" int main(int argc, char **argv) ...@@ -570,11 +570,11 @@ extern "C" int main(int argc, char **argv)
&app, SLOT(fileOpenRequested(QString))); &app, SLOT(fileOpenRequested(QString)));
// Hardware information // Hardware information
KisUsageLogger::write("\nHardware Information\n"); KisUsageLogger::writeSysInfo("\nHardware Information\n");
KisUsageLogger::write(QString(" GPU Acceleration: %1").arg(kritarc.value("OpenGLRenderer", "auto").toString())); KisUsageLogger::writeSysInfo(QString(" GPU Acceleration: %1").arg(kritarc.value("OpenGLRenderer", "auto").toString()));
KisUsageLogger::write(QString(" Memory: %1 Mb").arg(KisImageConfig(true).totalRAM())); KisUsageLogger::writeSysInfo(QString(" Memory: %1 Mb").arg(KisImageConfig(true).totalRAM()));
KisUsageLogger::write(QString(" Number of Cores: %1").arg(QThread::idealThreadCount())); KisUsageLogger::writeSysInfo(QString(" Number of Cores: %1").arg(QThread::idealThreadCount()));
KisUsageLogger::write(QString(" Swap Location: %1\n").arg(KisImageConfig(true).swapDir())); KisUsageLogger::writeSysInfo(QString(" Swap Location: %1\n").arg(KisImageConfig(true).swapDir()));
KisConfig(true).logImportantSettings(); KisConfig(true).logImportantSettings();
......
...@@ -39,15 +39,19 @@ const QString KisUsageLogger::s_sectionHeader("================================= ...@@ -39,15 +39,19 @@ const QString KisUsageLogger::s_sectionHeader("=================================
struct KisUsageLogger::Private { struct KisUsageLogger::Private {
bool active {false}; bool active {false};
QFile logFile; QFile logFile;
QFile sysInfoFile;
}; };
KisUsageLogger::KisUsageLogger() KisUsageLogger::KisUsageLogger()
: d(new Private) : d(new Private)
{ {
d->logFile.setFileName(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita.log"); d->logFile.setFileName(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita.log");
d->sysInfoFile.setFileName(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita-sysinfo.log");
rotateLog(); rotateLog();
d->logFile.open(QFile::Append | QFile::Text); d->logFile.open(QFile::Append | QFile::Text);
d->sysInfoFile.open(QFile::WriteOnly | QFile::Text);
} }
KisUsageLogger::~KisUsageLogger() KisUsageLogger::~KisUsageLogger()
...@@ -60,6 +64,37 @@ KisUsageLogger::~KisUsageLogger() ...@@ -60,6 +64,37 @@ KisUsageLogger::~KisUsageLogger()
void KisUsageLogger::initialize() void KisUsageLogger::initialize()
{ {
s_instance->d->active = true; s_instance->d->active = true;
QString systemInfo;
// NOTE: This is intentionally not translated!
// Krita version info
systemInfo.append("Krita\n");
systemInfo.append("\n Version: ").append(KritaVersionWrapper::versionString(true));
systemInfo.append("\n Languages: ").append(KLocalizedString::languages().join(", "));
systemInfo.append("\n Hidpi: ").append(QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) ? "true" : "false");
systemInfo.append("\n\n");
systemInfo.append("Qt\n");
systemInfo.append("\n Version (compiled): ").append(QT_VERSION_STR);
systemInfo.append("\n Version (loaded): ").append(qVersion());
systemInfo.append("\n\n");
// OS information
systemInfo.append("OS Information\n");
systemInfo.append("\n Build ABI: ").append(QSysInfo::buildAbi());
systemInfo.append("\n Build CPU: ").append(QSysInfo::buildCpuArchitecture());
systemInfo.append("\n CPU: ").append(QSysInfo::currentCpuArchitecture());
systemInfo.append("\n Kernel Type: ").append(QSysInfo::kernelType());
systemInfo.append("\n Kernel Version: ").append(QSysInfo::kernelVersion());
systemInfo.append("\n Pretty Productname: ").append(QSysInfo::prettyProductName());
systemInfo.append("\n Product Type: ").append(QSysInfo::productType());
systemInfo.append("\n Product Version: ").append(QSysInfo::productVersion());
systemInfo.append("\n\n");
s_instance->d->sysInfoFile.write(systemInfo.toUtf8());
} }
void KisUsageLogger::close() void KisUsageLogger::close()
...@@ -68,6 +103,8 @@ void KisUsageLogger::close() ...@@ -68,6 +103,8 @@ void KisUsageLogger::close()
s_instance->d->active = false; s_instance->d->active = false;
s_instance->d->logFile.flush(); s_instance->d->logFile.flush();
s_instance->d->logFile.close(); s_instance->d->logFile.close();
s_instance->d->sysInfoFile.flush();
s_instance->d->sysInfoFile.close();
} }
void KisUsageLogger::log(const QString &message) void KisUsageLogger::log(const QString &message)
...@@ -91,64 +128,30 @@ void KisUsageLogger::write(const QString &message) ...@@ -91,64 +128,30 @@ void KisUsageLogger::write(const QString &message)
s_instance->d->logFile.flush(); s_instance->d->logFile.flush();
} }
void KisUsageLogger::writeSectionHeader() void KisUsageLogger::writeSysInfo(const QString &message)
{ {
s_instance->d->logFile.write(s_sectionHeader.toUtf8()); if (!s_instance->d->active) return;
if (!s_instance->d->sysInfoFile.isOpen()) return;
s_instance->d->sysInfoFile.write(message.toUtf8());
s_instance->d->sysInfoFile.write("\n");
s_instance->d->sysInfoFile.flush();
} }
void KisUsageLogger::writeHeader() void KisUsageLogger::writeHeader()
{ {
Q_ASSERT(s_instance->d->logFile.isOpen()); Q_ASSERT(s_instance->d->sysInfoFile.isOpen());
s_instance->d->logFile.write(s_sectionHeader.toUtf8());
QString sessionHeader = QString("SESSION: %1. Executing %2\n\n") QString sessionHeader = QString("SESSION: %1. Executing %2\n\n")
.arg(QDateTime::currentDateTime().toString(Qt::RFC2822Date)) .arg(QDateTime::currentDateTime().toString(Qt::RFC2822Date))
.arg(qApp->arguments().join(' ')); .arg(qApp->arguments().join(' '));
QString disclaimer = i18n("WARNING: This file contains information about your system and the\n"
"images you have been working with.\n"
"\n"
"If you have problems with Krita, the Krita developers might ask\n"
"you to share this file with them. The information in this file is\n"
"not shared automatically with the Krita developers in any way. You\n"
"can disable logging to this file in Krita's Configure Krita Dialog.\n"
"\n"
"Please review the contents of this file before sharing this file with\n"
"anyone.\n\n");
QString systemInfo;
// NOTE: This is intentionally not translated!
// Krita version info
systemInfo.append("Krita\n");
systemInfo.append("\n Version: ").append(KritaVersionWrapper::versionString(true));
systemInfo.append("\n Languages: ").append(KLocalizedString::languages().join(", "));
systemInfo.append("\n Hidpi: ").append(QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) ? "true" : "false");
systemInfo.append("\n\n");
systemInfo.append("Qt\n");
systemInfo.append("\n Version (compiled): ").append(QT_VERSION_STR);
systemInfo.append("\n Version (loaded): ").append(qVersion());
systemInfo.append("\n\n");
// OS information
systemInfo.append("OS Information\n");
systemInfo.append("\n Build ABI: ").append(QSysInfo::buildAbi());
systemInfo.append("\n Build CPU: ").append(QSysInfo::buildCpuArchitecture());
systemInfo.append("\n CPU: ").append(QSysInfo::currentCpuArchitecture());
systemInfo.append("\n Kernel Type: ").append(QSysInfo::kernelType());
systemInfo.append("\n Kernel Version: ").append(QSysInfo::kernelVersion());
systemInfo.append("\n Pretty Productname: ").append(QSysInfo::prettyProductName());
systemInfo.append("\n Product Type: ").append(QSysInfo::productType());
systemInfo.append("\n Product Version: ").append(QSysInfo::productVersion());
systemInfo.append("\n\n");
writeSectionHeader();
s_instance->d->logFile.write(sessionHeader.toUtf8()); s_instance->d->logFile.write(sessionHeader.toUtf8());
s_instance->d->logFile.write(disclaimer.toUtf8()); s_instance->d->logFile.flush();
s_instance->d->logFile.write(systemInfo.toUtf8());
} }
void KisUsageLogger::rotateLog() void KisUsageLogger::rotateLog()
...@@ -158,7 +161,7 @@ void KisUsageLogger::rotateLog() ...@@ -158,7 +161,7 @@ void KisUsageLogger::rotateLog()
// Check for CLOSING SESSION // Check for CLOSING SESSION
d->logFile.open(QFile::ReadOnly); d->logFile.open(QFile::ReadOnly);
QString log = QString::fromUtf8(d->logFile.readAll()); QString log = QString::fromUtf8(d->logFile.readAll());
if (!log.split("\n").last().contains("CLOSING SESSION")) { if (!log.split(s_sectionHeader).last().contains("CLOSING SESSION")) {
log.append("\nKRITA DID NOT CLOSE CORRECTLY\n"); log.append("\nKRITA DID NOT CLOSE CORRECTLY\n");
QString crashLog = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/kritacrash.log"); QString crashLog = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/kritacrash.log");
if (QFileInfo(crashLog).exists()) { if (QFileInfo(crashLog).exists()) {
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
/// Writes without date/time /// Writes without date/time
static void write(const QString &message); static void write(const QString &message);
static void writeSectionHeader(); static void writeSysInfo(const QString &message);
static void writeHeader(); static void writeHeader();
......
...@@ -79,18 +79,18 @@ KisConfig::~KisConfig() ...@@ -79,18 +79,18 @@ KisConfig::~KisConfig()
void KisConfig::logImportantSettings() const void KisConfig::logImportantSettings() const
{ {
KisUsageLogger::write("Current Settings\n"); KisUsageLogger::writeSysInfo("Current Settings\n");
KisUsageLogger::write(QString("\tCurrent Swap Location: %1").arg(KisImageConfig(true).swapDir())); KisUsageLogger::writeSysInfo(QString(" Current Swap Location: %1").arg(KisImageConfig(true).swapDir()));
KisUsageLogger::write(QString("\tUndo Enabled: %1").arg(undoEnabled())); KisUsageLogger::writeSysInfo(QString(" Undo Enabled: %1").arg(undoEnabled()));
KisUsageLogger::write(QString("\tUndo Stack Limit: %1").arg(undoStackLimit())); KisUsageLogger::writeSysInfo(QString(" Undo Stack Limit: %1").arg(undoStackLimit()));
KisUsageLogger::write(QString("\tUse OpenGL: %1").arg(useOpenGL())); KisUsageLogger::writeSysInfo(QString(" Use OpenGL: %1").arg(useOpenGL()));
KisUsageLogger::write(QString("\tUse OpenGL Texture Buffer: %1").arg(useOpenGLTextureBuffer())); KisUsageLogger::writeSysInfo(QString(" Use OpenGL Texture Buffer: %1").arg(useOpenGLTextureBuffer()));
KisUsageLogger::write(QString("\tUse AMD Vectorization Workaround: %1").arg(enableAmdVectorizationWorkaround())); KisUsageLogger::writeSysInfo(QString(" Use AMD Vectorization Workaround: %1").arg(enableAmdVectorizationWorkaround()));
KisUsageLogger::write(QString("\tCanvas State: %1").arg(canvasState())); KisUsageLogger::writeSysInfo(QString(" Canvas State: %1").arg(canvasState()));
KisUsageLogger::write(QString("\tAutosave Interval: %1").arg(autoSaveInterval())); KisUsageLogger::writeSysInfo(QString(" Autosave Interval: %1").arg(autoSaveInterval()));
KisUsageLogger::write(QString("\tUse Backup Files: %1").arg(backupFile())); KisUsageLogger::writeSysInfo(QString(" Use Backup Files: %1").arg(backupFile()));
KisUsageLogger::write(QString("\tNumber of Backups Kept: %1").arg(m_cfg.readEntry("numberofbackupfiles", 1))); KisUsageLogger::writeSysInfo(QString(" Number of Backups Kept: %1").arg(m_cfg.readEntry("numberofbackupfiles", 1)));
KisUsageLogger::write(QString("\tBackup File Suffix: %1").arg(m_cfg.readEntry("backupfilesuffix", "~"))); KisUsageLogger::writeSysInfo(QString(" Backup File Suffix: %1").arg(m_cfg.readEntry("backupfilesuffix", "~")));
QString backupDir; QString backupDir;
switch(m_cfg.readEntry("backupfilelocation", 0)) { switch(m_cfg.readEntry("backupfilelocation", 0)) {
...@@ -104,14 +104,14 @@ void KisConfig::logImportantSettings() const ...@@ -104,14 +104,14 @@ void KisConfig::logImportantSettings() const
// Do nothing: the empty string is user file location // Do nothing: the empty string is user file location
backupDir = "Same Folder as the File"; backupDir = "Same Folder as the File";
} }
KisUsageLogger::write(QString("\tBackup Location: %1").arg(backupDir)); KisUsageLogger::writeSysInfo(QString(" Backup Location: %1").arg(backupDir));
KisUsageLogger::write(QString("\tUse Win8 Pointer Input: %1").arg(useWin8PointerInput())); KisUsageLogger::writeSysInfo(QString(" Use Win8 Pointer Input: %1").arg(useWin8PointerInput()));
KisUsageLogger::write(QString("\tUse RightMiddleTabletButton Workaround: %1").arg(useRightMiddleTabletButtonWorkaround())); KisUsageLogger::writeSysInfo(QString(" Use RightMiddleTabletButton Workaround: %1").arg(useRightMiddleTabletButtonWorkaround()));
KisUsageLogger::write(QString("\tLevels of Detail Enabled: %1").arg(levelOfDetailEnabled())); KisUsageLogger::writeSysInfo(QString(" Levels of Detail Enabled: %1").arg(levelOfDetailEnabled()));
KisUsageLogger::write(QString("\tUse Zip64: %1").arg(useZip64())); KisUsageLogger::writeSysInfo(QString(" Use Zip64: %1").arg(useZip64()));
KisUsageLogger::write("\n"); KisUsageLogger::writeSysInfo("\n");
} }
bool KisConfig::disableTouchOnCanvas(bool defaultValue) const bool KisConfig::disableTouchOnCanvas(bool defaultValue) const
......
...@@ -173,7 +173,7 @@ void KisOpenGL::initialize() ...@@ -173,7 +173,7 @@ void KisOpenGL::initialize()
// debugOut << "\n== end log =="; // debugOut << "\n== end log ==";
dbgOpenGL.noquote().nospace() << g_debugText; dbgOpenGL.noquote().nospace() << g_debugText;
KisUsageLogger::write(g_debugText); KisUsageLogger::writeSysInfo(g_debugText);
if (!openGLCheckResult) { if (!openGLCheckResult) {
return; return;
......
...@@ -90,10 +90,18 @@ DlgBugInfo::DlgBugInfo(QWidget *parent) ...@@ -90,10 +90,18 @@ DlgBugInfo::DlgBugInfo(QWidget *parent)
info.append("\n Swap: ").append(KisImageConfig(true).swapDir()); info.append("\n Swap: ").append(KisImageConfig(true).swapDir());
} }
else { else {
QFile f(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita.log");
f.open(QFile::ReadOnly | QFile::Text); QFile sysinfo(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita-sysinfo.log");
info = QString::fromUtf8(f.readAll()); sysinfo.open(QFile::ReadOnly | QFile::Text);
f.close(); info = QString::fromUtf8(sysinfo.readAll());
sysinfo.close();
info += "\n\n";
QFile log(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita.log");
log.open(QFile::ReadOnly | QFile::Text);
info += QString::fromUtf8(log.readAll());
log.close();
} }
// calculate a default height for the widget // calculate a default height for the widget
int wheight = m_page->sizeHint().height(); int wheight = m_page->sizeHint().height();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment