mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 13:07:04 +02:00
only enable logging if a log directory is passed
This commit is contained in:
parent
efa46b8c7b
commit
0b578bf086
4 changed files with 13 additions and 24 deletions
|
@ -96,9 +96,6 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||||
const QCommandLineOption logDirectoryOption(ASSIGNMENT_LOG_DIRECTORY, "directory to store logs", "log-directory");
|
const QCommandLineOption logDirectoryOption(ASSIGNMENT_LOG_DIRECTORY, "directory to store logs", "log-directory");
|
||||||
parser.addOption(logDirectoryOption);
|
parser.addOption(logDirectoryOption);
|
||||||
|
|
||||||
const QCommandLineOption noLogFileOption(ASSIGNMENT_NO_CHILD_LOG_FILE_OPTION, "disable writing of child assignment-client output to file");
|
|
||||||
parser.addOption(noLogFileOption);
|
|
||||||
|
|
||||||
if (!parser.parse(QCoreApplication::arguments())) {
|
if (!parser.parse(QCoreApplication::arguments())) {
|
||||||
qCritical() << parser.errorText() << endl;
|
qCritical() << parser.errorText() << endl;
|
||||||
parser.showHelp();
|
parser.showHelp();
|
||||||
|
@ -142,17 +139,10 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||||
httpStatusPort = parser.value(httpStatusPortOption).toUShort();
|
httpStatusPort = parser.value(httpStatusPortOption).toUShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wantsChildFileLogging = false;
|
QString logDirectory;
|
||||||
QDir logDirectory { "." };
|
|
||||||
|
|
||||||
if (!parser.isSet(noLogFileOption)) {
|
if (parser.isSet(logDirectoryOption)) {
|
||||||
wantsChildFileLogging = true;
|
logDirectory = parser.value(logDirectoryOption);
|
||||||
|
|
||||||
if (parser.isSet(logDirectoryOption)) {
|
|
||||||
logDirectory = parser.value(logDirectoryOption);
|
|
||||||
} else {
|
|
||||||
logDirectory = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,8 +216,7 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||||
AssignmentClientMonitor* monitor = new AssignmentClientMonitor(numForks, minForks, maxForks,
|
AssignmentClientMonitor* monitor = new AssignmentClientMonitor(numForks, minForks, maxForks,
|
||||||
requestAssignmentType, assignmentPool,
|
requestAssignmentType, assignmentPool,
|
||||||
listenPort, walletUUID, assignmentServerHostname,
|
listenPort, walletUUID, assignmentServerHostname,
|
||||||
assignmentServerPort, httpStatusPort, logDirectory,
|
assignmentServerPort, httpStatusPort, logDirectory);
|
||||||
wantsChildFileLogging);
|
|
||||||
monitor->setParent(this);
|
monitor->setParent(this);
|
||||||
connect(this, &QCoreApplication::aboutToQuit, monitor, &AssignmentClientMonitor::aboutToQuit);
|
connect(this, &QCoreApplication::aboutToQuit, monitor, &AssignmentClientMonitor::aboutToQuit);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,7 +27,6 @@ const QString ASSIGNMENT_MAX_FORKS_OPTION = "max";
|
||||||
const QString ASSIGNMENT_CLIENT_MONITOR_PORT_OPTION = "monitor-port";
|
const QString ASSIGNMENT_CLIENT_MONITOR_PORT_OPTION = "monitor-port";
|
||||||
const QString ASSIGNMENT_HTTP_STATUS_PORT = "http-status-port";
|
const QString ASSIGNMENT_HTTP_STATUS_PORT = "http-status-port";
|
||||||
const QString ASSIGNMENT_LOG_DIRECTORY = "log-directory";
|
const QString ASSIGNMENT_LOG_DIRECTORY = "log-directory";
|
||||||
const QString ASSIGNMENT_NO_CHILD_LOG_FILE_OPTION = "no-child-log-files";
|
|
||||||
|
|
||||||
class AssignmentClientApp : public QCoreApplication {
|
class AssignmentClientApp : public QCoreApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -33,9 +33,7 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen
|
||||||
const unsigned int maxAssignmentClientForks,
|
const unsigned int maxAssignmentClientForks,
|
||||||
Assignment::Type requestAssignmentType, QString assignmentPool,
|
Assignment::Type requestAssignmentType, QString assignmentPool,
|
||||||
quint16 listenPort, QUuid walletUUID, QString assignmentServerHostname,
|
quint16 listenPort, QUuid walletUUID, QString assignmentServerHostname,
|
||||||
quint16 assignmentServerPort, quint16 httpStatusServerPort, QDir logDirectory,
|
quint16 assignmentServerPort, quint16 httpStatusServerPort, QString logDirectory) :
|
||||||
bool wantsChildFileLogging) :
|
|
||||||
_logDirectory(logDirectory),
|
|
||||||
_httpManager(QHostAddress::LocalHost, httpStatusServerPort, "", this),
|
_httpManager(QHostAddress::LocalHost, httpStatusServerPort, "", this),
|
||||||
_numAssignmentClientForks(numAssignmentClientForks),
|
_numAssignmentClientForks(numAssignmentClientForks),
|
||||||
_minAssignmentClientForks(minAssignmentClientForks),
|
_minAssignmentClientForks(minAssignmentClientForks),
|
||||||
|
@ -44,12 +42,16 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen
|
||||||
_assignmentPool(assignmentPool),
|
_assignmentPool(assignmentPool),
|
||||||
_walletUUID(walletUUID),
|
_walletUUID(walletUUID),
|
||||||
_assignmentServerHostname(assignmentServerHostname),
|
_assignmentServerHostname(assignmentServerHostname),
|
||||||
_assignmentServerPort(assignmentServerPort),
|
_assignmentServerPort(assignmentServerPort)
|
||||||
_wantsChildFileLogging(wantsChildFileLogging)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
qDebug() << "_requestAssignmentType =" << _requestAssignmentType;
|
qDebug() << "_requestAssignmentType =" << _requestAssignmentType;
|
||||||
|
|
||||||
|
if (!logDirectory.isEmpty()) {
|
||||||
|
_wantsChildFileLogging = true;
|
||||||
|
_logDirectory = QDir(logDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
// start the Logging class with the parent's target name
|
// start the Logging class with the parent's target name
|
||||||
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME);
|
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME);
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,7 @@ public:
|
||||||
AssignmentClientMonitor(const unsigned int numAssignmentClientForks, const unsigned int minAssignmentClientForks,
|
AssignmentClientMonitor(const unsigned int numAssignmentClientForks, const unsigned int minAssignmentClientForks,
|
||||||
const unsigned int maxAssignmentClientForks, Assignment::Type requestAssignmentType,
|
const unsigned int maxAssignmentClientForks, Assignment::Type requestAssignmentType,
|
||||||
QString assignmentPool, quint16 listenPort, QUuid walletUUID, QString assignmentServerHostname,
|
QString assignmentPool, quint16 listenPort, QUuid walletUUID, QString assignmentServerHostname,
|
||||||
quint16 assignmentServerPort, quint16 httpStatusServerPort, QDir logDirectory,
|
quint16 assignmentServerPort, quint16 httpStatusServerPort, QString logDirectory);
|
||||||
bool wantsChildFileLogging);
|
|
||||||
~AssignmentClientMonitor();
|
~AssignmentClientMonitor();
|
||||||
|
|
||||||
void stopChildProcesses();
|
void stopChildProcesses();
|
||||||
|
@ -75,7 +74,7 @@ private:
|
||||||
|
|
||||||
QMap<qint64, ACProcess> _childProcesses;
|
QMap<qint64, ACProcess> _childProcesses;
|
||||||
|
|
||||||
bool _wantsChildFileLogging;
|
bool _wantsChildFileLogging { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AssignmentClientMonitor_h
|
#endif // hifi_AssignmentClientMonitor_h
|
||||||
|
|
Loading…
Reference in a new issue