forked from qt-creator/qt-creator
Qbs: Be more paranoid when setting the log level
Change-Id: I134c6eefeff285ed8953c7b35c249ea757692c34 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -93,12 +93,15 @@ QbsManager::QbsManager(Internal::QbsProjectManagerPlugin *plugin) :
|
|||||||
int level = qbs::LoggerWarning;
|
int level = qbs::LoggerWarning;
|
||||||
const QString levelEnv = QString::fromLocal8Bit(qgetenv("QBS_LOG_LEVEL"));
|
const QString levelEnv = QString::fromLocal8Bit(qgetenv("QBS_LOG_LEVEL"));
|
||||||
if (!levelEnv.isEmpty()) {
|
if (!levelEnv.isEmpty()) {
|
||||||
int tmp = levelEnv.toInt();
|
bool ok = false;
|
||||||
if (tmp < static_cast<int>(qbs::LoggerMinLevel))
|
int tmp = levelEnv.toInt(&ok);
|
||||||
tmp = static_cast<int>(qbs::LoggerMinLevel);
|
if (ok) {
|
||||||
if (tmp > static_cast<int>(qbs::LoggerMaxLevel))
|
if (tmp < static_cast<int>(qbs::LoggerMinLevel))
|
||||||
tmp = static_cast<int>(qbs::LoggerMaxLevel);
|
tmp = static_cast<int>(qbs::LoggerMinLevel);
|
||||||
level = tmp;
|
if (tmp > static_cast<int>(qbs::LoggerMaxLevel))
|
||||||
|
tmp = static_cast<int>(qbs::LoggerMaxLevel);
|
||||||
|
level = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_logSink->setLogLevel(static_cast<qbs::LoggerLevel>(level));
|
m_logSink->setLogLevel(static_cast<qbs::LoggerLevel>(level));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user