mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
Changed: Logs in Ryzom Installer
This commit is contained in:
parent
004d88b989
commit
ab9564c830
8 changed files with 108 additions and 11 deletions
|
@ -272,6 +272,8 @@ void CDownloader::onHeadFinished()
|
|||
{
|
||||
if (redirection.isEmpty())
|
||||
{
|
||||
nlwarning("No redirection defined");
|
||||
|
||||
if (m_listener) m_listener->operationFail(tr("Redirection URL is not defined"));
|
||||
return;
|
||||
}
|
||||
|
@ -298,6 +300,8 @@ void CDownloader::onHeadFinished()
|
|||
|
||||
if (!m_supportsAcceptRanges && acceptRanges == "bytes")
|
||||
{
|
||||
nlinfo("Server supports resume for %s", Q2C(url));
|
||||
|
||||
// server supports resume, part 1
|
||||
m_supportsAcceptRanges = true;
|
||||
|
||||
|
@ -309,6 +313,7 @@ void CDownloader::onHeadFinished()
|
|||
// server doesn't support resume or
|
||||
// we requested range, but server always returns 200
|
||||
// download from the beginning
|
||||
nlwarning("Server doesn't support resume, download %s from the beginning", Q2C(url));
|
||||
}
|
||||
|
||||
// we requested with a range
|
||||
|
@ -327,10 +332,12 @@ void CDownloader::onHeadFinished()
|
|||
|
||||
// update offset and size
|
||||
if (m_listener) m_listener->operationInit(m_offset, m_size);
|
||||
|
||||
nlinfo("Server supports resume for %s: offset %" NL_I64 "d, size %" NL_I64 "d", Q2C(url), m_offset, m_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unable to parse";
|
||||
nlwarning("Unable to parse %s", Q2C(contentRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,17 +132,18 @@ void CInstallDialog::accept()
|
|||
// check free disk space
|
||||
qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData());
|
||||
|
||||
// shouldn't happen
|
||||
if (freeSpace == 0)
|
||||
{
|
||||
QString error = qFromUtf8(NLMISC::formatErrorMessage(NLMISC::getLastError()));
|
||||
int error = NLMISC::getLastError();
|
||||
|
||||
QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Error"), tr("Error '%1' occured when trying to check free disk space on %2.").arg(error).arg(m_dstDirectory));
|
||||
return;
|
||||
nlwarning("Error '%s' (%d) occured when trying to check free disk space on %s, continue anyway", NLMISC::formatErrorMessage(error).c_str(), error, Q2C(m_dstDirectory));
|
||||
}
|
||||
|
||||
const CServer &server = CConfigFile::getInstance()->getServer();
|
||||
|
||||
if (freeSpace < server.dataUncompressedSize)
|
||||
// compare with exact size of current directory
|
||||
if (freeSpace && freeSpace < server.dataUncompressedSize)
|
||||
{
|
||||
QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Not enough free disk space"), tr("You don't have enough free space on this disk, please make more space or choose a directory on another disk."));
|
||||
return;
|
||||
|
|
|
@ -152,6 +152,11 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
// init log
|
||||
CLogHelper logHelper(config.getInstallationDirectory());
|
||||
|
||||
nlinfo("Launched %s", Q2C(config.getInstallerCurrentFilePath()));
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(_DEBUG)
|
||||
// under Windows, Ryzom Installer should always be copied in TEMP directory
|
||||
QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
|
@ -159,6 +164,8 @@ int main(int argc, char *argv[])
|
|||
// check if launched from TEMP directory
|
||||
if (step == Done && !config.getInstallerCurrentDirPath().startsWith(tempPath))
|
||||
{
|
||||
nlinfo("Not launched from TEMP directory");
|
||||
|
||||
// try to delete all temporary installers
|
||||
QDir tempDir(tempPath);
|
||||
|
||||
|
@ -173,17 +180,25 @@ int main(int argc, char *argv[])
|
|||
QDir dirToRemove(tempDir);
|
||||
dirToRemove.cd(dir);
|
||||
dirToRemove.removeRecursively();
|
||||
|
||||
nlinfo("Delete directory %s", Q2C(dir));
|
||||
}
|
||||
|
||||
tempPath += QString("/ryzom_installer_%1").arg(QDateTime::currentMSecsSinceEpoch());
|
||||
|
||||
nlinfo("Creating directory %s", Q2C(tempPath));
|
||||
|
||||
// copy installer and required files to TEMP directory
|
||||
if (QDir().mkdir(tempPath) && copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath))
|
||||
{
|
||||
QString tempFile = tempPath + "/" + QFileInfo(config.getInstallerCurrentFilePath()).fileName();
|
||||
|
||||
nlinfo("Launching %s", Q2C(tempFile));
|
||||
|
||||
// launch copy in TEMP directory with same arguments
|
||||
if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0;
|
||||
|
||||
nlwarning("Unable to launch %s", Q2C(tempFile));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -193,6 +208,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (parser.isSet(uninstallOption))
|
||||
{
|
||||
nlinfo("Uninstalling...");
|
||||
|
||||
SComponents components;
|
||||
|
||||
// add all servers by default
|
||||
|
@ -227,6 +244,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (step == ShowMigrateWizard)
|
||||
{
|
||||
nlinfo("Display migration dialog");
|
||||
|
||||
CMigrateDialog dialog;
|
||||
|
||||
if (!dialog.exec()) return 1;
|
||||
|
@ -235,6 +254,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
else if (step == ShowInstallWizard)
|
||||
{
|
||||
nlinfo("Display installation dialog");
|
||||
|
||||
CInstallDialog dialog;
|
||||
|
||||
if (!dialog.exec()) return 1;
|
||||
|
@ -242,6 +263,8 @@ int main(int argc, char *argv[])
|
|||
step = config.getInstallNextStep();
|
||||
}
|
||||
|
||||
nlinfo("Next step is %s", Q2C(stepToString(step)));
|
||||
|
||||
bool restartInstaller = false;
|
||||
|
||||
if (step != Done)
|
||||
|
@ -254,6 +277,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
step = config.getInstallNextStep();
|
||||
|
||||
nlinfo("Last step is %s", Q2C(stepToString(step)));
|
||||
|
||||
if (step == LaunchInstalledInstaller)
|
||||
{
|
||||
// restart more recent installed Installer version
|
||||
|
@ -271,6 +296,8 @@ int main(int argc, char *argv[])
|
|||
if (restartInstaller)
|
||||
{
|
||||
#ifndef _DEBUG
|
||||
nlinfo("Restart Installer %s", Q2C(config.getInstallerInstalledFilePath()));
|
||||
|
||||
#ifndef Q_OS_WIN32
|
||||
// fix executable permissions under UNIX
|
||||
QFile::setPermissions(config.getInstallerInstalledFilePath(), QFile::permissions(config.getInstallerInstalledFilePath()) | QFile::ExeGroup | QFile::ExeUser | QFile::ExeOther);
|
||||
|
|
|
@ -147,16 +147,16 @@ void CMigrateDialog::accept()
|
|||
// check free disk space
|
||||
qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData());
|
||||
|
||||
// shouldn't happen
|
||||
if (freeSpace == 0)
|
||||
{
|
||||
QString error = qFromUtf8(NLMISC::formatErrorMessage(NLMISC::getLastError()));
|
||||
int error = NLMISC::getLastError();
|
||||
|
||||
QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Error"), tr("Error '%1' occured when trying to check free disk space on %2.").arg(error).arg(m_dstDirectory));
|
||||
return;
|
||||
nlwarning("Error '%s' (%d) occured when trying to check free disk space on %s, continue anyway", NLMISC::formatErrorMessage(error).c_str(), error, Q2C(m_dstDirectory));
|
||||
}
|
||||
|
||||
// compare with exact size of current directory
|
||||
if (freeSpace < getDirectorySize(m_currentDirectory, true))
|
||||
if (freeSpace && freeSpace < getDirectorySize(m_currentDirectory, true))
|
||||
{
|
||||
QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Not enough free disk space"), tr("You don't have enough free space on this disk, please make more space or choose a directory on another disk."));
|
||||
return;
|
||||
|
|
|
@ -73,6 +73,8 @@ enum OperationStep
|
|||
Done
|
||||
};
|
||||
|
||||
QString stepToString(OperationStep);
|
||||
|
||||
enum OperationType
|
||||
{
|
||||
OperationNone,
|
||||
|
|
|
@ -54,8 +54,10 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/misc/config_file.h>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/system_info.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -563,3 +563,51 @@ CCOMHelper::~CCOMHelper()
|
|||
if (m_mustUninit) CoUninitialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
CLogHelper::CLogHelper(const QString &logPath)
|
||||
{
|
||||
// disable nldebug messages in logs in Release
|
||||
#ifdef NL_RELEASE
|
||||
NLMISC::DisableNLDebug = true;
|
||||
#endif
|
||||
|
||||
// don't create a file for the moment, we'll create it manually
|
||||
NLMISC::createDebug(NULL, false);
|
||||
|
||||
// ryzom_installer.Log displayer
|
||||
NLMISC::CFileDisplayer *LogDisplayer = new NLMISC::CFileDisplayer(qToUtf8(logPath) + "/ryzom_installer.log", true, "DEFAULT_FD");
|
||||
NLMISC::DebugLog->addDisplayer(LogDisplayer);
|
||||
NLMISC::InfoLog->addDisplayer(LogDisplayer);
|
||||
NLMISC::WarningLog->addDisplayer(LogDisplayer);
|
||||
NLMISC::ErrorLog->addDisplayer(LogDisplayer);
|
||||
NLMISC::AssertLog->addDisplayer(LogDisplayer);
|
||||
|
||||
std::string type;
|
||||
|
||||
#ifdef NL_RELEASE
|
||||
type = "RELEASE";
|
||||
#else
|
||||
type = "DEBUG";
|
||||
#endif
|
||||
|
||||
// Display installer version
|
||||
nlinfo("RYZOM INSTALLER VERSION: %s (%s)", Q2C(QApplication::applicationVersion()), type.c_str());
|
||||
nlinfo("Memory: %s/%s", NLMISC::bytesToHumanReadable(NLMISC::CSystemInfo::availablePhysicalMemory()).c_str(), NLMISC::bytesToHumanReadable(NLMISC::CSystemInfo::totalPhysicalMemory()).c_str());
|
||||
nlinfo("OS: %s", NLMISC::CSystemInfo::getOS().c_str());
|
||||
nlinfo("Processor: %s", NLMISC::CSystemInfo::getProc().c_str());
|
||||
}
|
||||
|
||||
CLogHelper::~CLogHelper()
|
||||
{
|
||||
NLMISC::IDisplayer *LogDisplayer = NLMISC::ErrorLog->getDisplayer("DEFAULT_FD");
|
||||
|
||||
if (LogDisplayer)
|
||||
{
|
||||
NLMISC::DebugLog->removeDisplayer(LogDisplayer);
|
||||
NLMISC::InfoLog->removeDisplayer(LogDisplayer);
|
||||
NLMISC::WarningLog->removeDisplayer(LogDisplayer);
|
||||
NLMISC::ErrorLog->removeDisplayer(LogDisplayer);
|
||||
NLMISC::AssertLog->removeDisplayer(LogDisplayer);
|
||||
delete LogDisplayer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ QString qFromWide(const wchar_t *str);
|
|||
// convert an QString to wchar_t*
|
||||
wchar_t* qToWide(const QString &str);
|
||||
|
||||
#define Q2C(x) qToUtf8(x).c_str()
|
||||
|
||||
// check if a shortcut already exists (the extension will be added)
|
||||
bool shortcutExists(const QString &shortcut);
|
||||
|
||||
|
@ -92,4 +94,12 @@ public:
|
|||
~CCOMHelper();
|
||||
};
|
||||
|
||||
// a little helper class to init/uninit log
|
||||
class CLogHelper
|
||||
{
|
||||
public:
|
||||
CLogHelper(const QString &logPath);
|
||||
~CLogHelper();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue