Skip to content

Commit 6fe6394

Browse files
committedAug 30, 2017
Make crssync quiet by default
We only need it to show up in the build log if something has gone wrong. By default we will just happily assume that it's doing a great job in all conscience.
1 parent 3b997c2 commit 6fe6394

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed
 

‎src/core/qgsapplication.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ void QgsApplication::init( QString profileFolder )
167167
ABISYM( mRunningFromBuildDir ) = true;
168168
ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
169169
ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
170-
qDebug( "Running from build directory!" );
171-
qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toUtf8().data() );
172-
qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toUtf8().data() );
170+
QgsDebugMsgLevel( QStringLiteral( "Running from build directory!" ), 4 );
171+
QgsDebugMsgLevel( QStringLiteral( "- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().data() ), 4 );
172+
QgsDebugMsgLevel( QStringLiteral( "- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().data() ), 4 );
173173
#ifdef _MSC_VER
174174
ABISYM( mCfgIntDir ) = prefixPath.split( '/', QString::SkipEmptyParts ).last();
175175
qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().data() );

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ QString QgsCoordinateReferenceSystem::quotedValue( QString value )
17151715
// adapted from gdal/ogr/ogr_srs_dict.cpp
17161716
bool QgsCoordinateReferenceSystem::loadWkts( QHash<int, QString> &wkts, const char *filename )
17171717
{
1718-
qDebug( "Loading %s", filename );
1718+
QgsDebugMsgLevel( QStringLiteral( "Loading %1" ).arg( filename ), 4 );
17191719
const char *pszFilename = CPLFindFile( "gdal", filename );
17201720
if ( !pszFilename )
17211721
return false;
@@ -1826,7 +1826,7 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )
18261826

18271827
f.close();
18281828

1829-
qDebug( "Loaded %d/%d from %s", n, l, filename.toUtf8().constData() );
1829+
QgsDebugMsgLevel( QStringLiteral( "Loaded %1/%2 from %3" ).arg( QString::number( n ), QString::number( l ), filename.toUtf8().constData() ), 4 );
18301830
}
18311831

18321832
OSRDestroySpatialReference( crs );
@@ -1841,7 +1841,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
18411841

18421842
int inserted = 0, updated = 0, deleted = 0, errors = 0;
18431843

1844-
qDebug( "Load srs db from: %s", QgsApplication::srsDatabaseFilePath().toLocal8Bit().constData() );
1844+
QgsDebugMsgLevel( QStringLiteral( "Load srs db from: %1" ).arg( QgsApplication::srsDatabaseFilePath().toLocal8Bit().constData() ), 4 );
18451845

18461846
sqlite3 *database = nullptr;
18471847
if ( sqlite3_open( dbFilePath.toUtf8().constData(), &database ) != SQLITE_OK )
@@ -1874,7 +1874,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
18741874
loadIds( wkts );
18751875
loadWkts( wkts, "epsg.wkt" );
18761876

1877-
qDebug( "%d WKTs loaded", wkts.count() );
1877+
QgsDebugMsgLevel( QStringLiteral( "%1 WKTs loaded" ).arg( wkts.count() ), 4 );
18781878

18791879
for ( QHash<int, QString>::const_iterator it = wkts.constBegin(); it != wkts.constEnd(); ++it )
18801880
{
@@ -2114,7 +2114,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
21142114

21152115
sqlite3_close( database );
21162116

2117-
qWarning( "CRS update (inserted:%d updated:%d deleted:%d errors:%d)", inserted, updated, deleted, errors );
2117+
QgsDebugMsgLevel( QStringLiteral( "CRS update (inserted:%1 updated:%2 deleted:%3 errors:%4)" ).arg( QString::number( inserted ), QString::number( updated ), QString::number( deleted ), QString::number( errors ) ), 4 );
21182118

21192119
if ( errors > 0 )
21202120
return -errors;

‎src/crssync/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ int main( int argc, char **argv )
4040
{
4141
QCoreApplication app( argc, argv );
4242

43+
const QStringList args = QCoreApplication::arguments();
44+
45+
bool verbose = false;
46+
47+
for ( const QString &arg : args )
48+
{
49+
if ( arg == QLatin1String( "--verbose" ) )
50+
verbose = true;
51+
}
52+
4353
QgsApplication::init();
4454

4555
if ( !QgsApplication::isRunningFromBuildDir() )
@@ -48,19 +58,20 @@ int main( int argc, char **argv )
4858
QgsApplication::setPrefixPath( prefixPath ? prefixPath : CMAKE_INSTALL_PREFIX, TRUE );
4959
}
5060

51-
std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;
61+
if ( verbose )
62+
std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;
5263

5364
CPLPushErrorHandler( showError );
5465

5566
int res = QgsCoordinateReferenceSystem::syncDatabase();
5667

5768
CPLPopErrorHandler();
5869

59-
if ( res == 0 )
70+
if ( res == 0 && verbose )
6071
{
6172
std::cout << "No CRS updates were necessary." << std::endl;
6273
}
63-
else if ( res > 0 )
74+
else if ( res > 0 && verbose )
6475
{
6576
std::cout << res << " CRSs updated." << std::endl;
6677
}

0 commit comments

Comments
 (0)
Please sign in to comment.