mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-06 05:53:53 +02:00
Improve error reporting for incorrect --logOptions
This commit is contained in:
parent
545ee0840b
commit
214dce833d
5 changed files with 8 additions and 7 deletions
|
@ -129,7 +129,7 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
|||
// We want to configure the logging system as early as possible
|
||||
auto &logHandler = LogHandler::getInstance();
|
||||
if (parser.isSet(logOption)) {
|
||||
if (!logHandler.parseOptions(parser.value(logOption).toUtf8())) {
|
||||
if (!logHandler.parseOptions(parser.value(logOption).toUtf8(), logOption.names().first())) {
|
||||
QCoreApplication mockApp(argc, const_cast<char**>(argv)); // required for call to showHelp()
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
|
|
|
@ -442,7 +442,7 @@ void DomainServer::parseCommandLine(int argc, char* argv[]) {
|
|||
// We want to configure the logging system as early as possible
|
||||
auto &logHandler = LogHandler::getInstance();
|
||||
if (parser.isSet(logOption)) {
|
||||
if (!logHandler.parseOptions(parser.value(logOption).toUtf8())) {
|
||||
if (!logHandler.parseOptions(parser.value(logOption).toUtf8(), logOption.names().first())) {
|
||||
QCoreApplication mockApp(argc, const_cast<char**>(argv)); // required for call to showHelp()
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
|
|
|
@ -311,7 +311,7 @@ int main(int argc, const char* argv[]) {
|
|||
// We want to configure the logging system as early as possible
|
||||
auto &logHandler = LogHandler::getInstance();
|
||||
if (parser.isSet(logOption)) {
|
||||
if (!logHandler.parseOptions(parser.value(logOption).toUtf8())) {
|
||||
if (!logHandler.parseOptions(parser.value(logOption).toUtf8(), logOption.names().first())) {
|
||||
QCoreApplication mockApp(argc, const_cast<char**>(argv)); // required for call to showHelp()
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
|
|
|
@ -61,7 +61,7 @@ LogHandler::LogHandler() {
|
|||
_useJournald = true;
|
||||
#endif
|
||||
|
||||
parseOptions(logOptions);
|
||||
parseOptions(logOptions, "VIRCADIA_LOG_OPTIONS");
|
||||
}
|
||||
|
||||
const char* stringForLogType(LogMsgType msgType) {
|
||||
|
@ -121,7 +121,7 @@ const QString DATE_STRING_FORMAT = "MM/dd hh:mm:ss";
|
|||
// the following will produce 11/18 13:55:36.999
|
||||
const QString DATE_STRING_FORMAT_WITH_MILLISECONDS = "MM/dd hh:mm:ss.zzz";
|
||||
|
||||
bool LogHandler::parseOptions(QString logOptions) {
|
||||
bool LogHandler::parseOptions(const QString& logOptions, const QString& paramName) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
auto optionList = logOptions.split(",");
|
||||
|
||||
|
@ -145,7 +145,7 @@ bool LogHandler::parseOptions(QString logOptions) {
|
|||
} else if (option == "nojournald") {
|
||||
_useJournald = false;
|
||||
} else if (option != "") {
|
||||
fprintf(stdout, "Unrecognized option in VIRCADIA_LOG_OPTIONS: '%s'\n", option.toUtf8().constData());
|
||||
fprintf(stderr, "Unrecognized option in %s: '%s'\n", paramName.toUtf8().constData(), option.toUtf8().constData());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,11 @@ public:
|
|||
* This parses the logging settings in the environment variable, or from the commandline
|
||||
*
|
||||
* @param options Option list
|
||||
* @param paramName Name of the log option, for error reporting.
|
||||
* @return true Option list was parsed successfully
|
||||
* @return false There was an error
|
||||
*/
|
||||
bool parseOptions(QString options);
|
||||
bool parseOptions(const QString& options, const QString ¶mName);
|
||||
|
||||
/**
|
||||
* @brief Set the name of the component that's producing log output
|
||||
|
|
Loading…
Reference in a new issue