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;
|
||||
const QString levelEnv = QString::fromLocal8Bit(qgetenv("QBS_LOG_LEVEL"));
|
||||
if (!levelEnv.isEmpty()) {
|
||||
int tmp = levelEnv.toInt();
|
||||
if (tmp < static_cast<int>(qbs::LoggerMinLevel))
|
||||
tmp = static_cast<int>(qbs::LoggerMinLevel);
|
||||
if (tmp > static_cast<int>(qbs::LoggerMaxLevel))
|
||||
tmp = static_cast<int>(qbs::LoggerMaxLevel);
|
||||
level = tmp;
|
||||
bool ok = false;
|
||||
int tmp = levelEnv.toInt(&ok);
|
||||
if (ok) {
|
||||
if (tmp < static_cast<int>(qbs::LoggerMinLevel))
|
||||
tmp = static_cast<int>(qbs::LoggerMinLevel);
|
||||
if (tmp > static_cast<int>(qbs::LoggerMaxLevel))
|
||||
tmp = static_cast<int>(qbs::LoggerMaxLevel);
|
||||
level = tmp;
|
||||
}
|
||||
}
|
||||
m_logSink->setLogLevel(static_cast<qbs::LoggerLevel>(level));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user