[welcome] Log where GeoIP information came from, if it's unusable

- This helps chase down broken GeoIP configurations, since you
   can check the URL and handler type shown in the log.
This commit is contained in:
Adriaan de Groot 2019-06-18 12:24:30 +02:00
parent 6183c4e2f4
commit 3967f6c5ae
2 changed files with 24 additions and 4 deletions

View File

@ -133,7 +133,7 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
QString countryResult = f->future().result();
cDebug() << "GeoIP result for welcome=" << countryResult;
view->setCountry( countryResult );
view->setCountry( countryResult, h );
f->deleteLater();
delete h;
} );
@ -156,12 +156,22 @@ WelcomeViewStep::checkRequirements()
return m_requirementsChecker->checkRequirements();
}
static inline void
logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler )
{
if ( handler )
{
cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " (" << static_cast<int>( handler->type() ) << handler->selector() << ')';
}
}
void
WelcomeViewStep::setCountry( const QString& countryCode )
WelcomeViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::Handler* handler )
{
if ( countryCode.length() != 2 )
{
cDebug() << "Unusable country code" << countryCode;
logGeoIPHandler( handler );
return;
}
@ -169,6 +179,7 @@ WelcomeViewStep::setCountry( const QString& countryCode )
if ( c_l.first == QLocale::Country::AnyCountry )
{
cDebug() << "Unusable country code" << countryCode;
logGeoIPHandler( handler );
return;
}
else

View File

@ -32,6 +32,14 @@
class WelcomePage;
class GeneralRequirements;
namespace CalamaresUtils
{
namespace GeoIP
{
class Handler;
}
} // namespace
class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep
{
Q_OBJECT
@ -57,9 +65,10 @@ public:
/** @brief Sets the country that Calamares is running in.
*
* This (ideally) sets up language and locale settings that are right for
* the given 2-letter country code.
* the given 2-letter country code. Uses the handler's information (if
* given) for error reporting.
*/
void setCountry( const QString& );
void setCountry( const QString&, CalamaresUtils::GeoIP::Handler* handler );
Calamares::RequirementsList checkRequirements() override;