Skip to content

Commit f1fd152

Browse files
committedApr 11, 2023
Make grass plugin/provider less debug heavy
1 parent 9aaf085 commit f1fd152

12 files changed

+157
-157
lines changed
 

‎src/plugins/grass/qgsgrassmoduleoptions.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
6969
, mXName( xname )
7070
{
7171
//QgsDebugMsgLevel( "called.", 4 );
72-
QgsDebugMsg( QString( "PATH = %1" ).arg( getenv( "PATH" ) ) );
72+
QgsDebugMsgLevel( QString( "PATH = %1" ).arg( getenv( "PATH" ) ), 2 );
7373

7474
//
7575
//Set up dynamic inside a scroll box
@@ -153,7 +153,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
153153
}
154154

155155
QString optionType = confDomElement.tagName();
156-
QgsDebugMsg( "optionType = " + optionType );
156+
QgsDebugMsgLevel( "optionType = " + optionType, 3 );
157157

158158
if ( confDomElement.attribute( QStringLiteral( "advanced" ), QStringLiteral( "no" ) ) == QLatin1String( "yes" ) )
159159
{
@@ -165,7 +165,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
165165
}
166166

167167
QString key = confDomElement.attribute( QStringLiteral( "key" ) );
168-
QgsDebugMsg( "key = " + key );
168+
QgsDebugMsgLevel( "key = " + key, 3 );
169169

170170
QDomNode gnode = QgsGrassModuleParam::nodeByKey( descDocElem, key );
171171
if ( gnode.isNull() )
@@ -187,7 +187,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
187187
QString element = promptElem.attribute( QStringLiteral( "element" ) );
188188
QString age = promptElem.attribute( QStringLiteral( "age" ) );
189189

190-
//QgsDebugMsg("element = " + element + " age = " + age);
190+
//QgsDebugMsgLevel("element = " + element + " age = " + age, 3);
191191
if ( age == QLatin1String( "old" ) && ( element == QLatin1String( "vector" ) || element == QLatin1String( "cell" ) ||
192192
element == QLatin1String( "strds" ) || element == QLatin1String( "stvds" ) ||
193193
element == QLatin1String( "str3ds" ) || element == QLatin1String( "stds" ) )
@@ -218,7 +218,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
218218
// G_OPT_DB_COLUMN may be also used for new columns (v.in.db) so we check also if there is at least one input vector
219219
// but a vector input may also exist (v.random).
220220
QList<QDomNode> vectorNodes = QgsGrassModuleParam::nodesByType( descDocElem, G_OPT_V_INPUT, QStringLiteral( "old" ) );
221-
QgsDebugMsg( QString( "vectorNodes.size() = %1" ).arg( vectorNodes.size() ) );
221+
QgsDebugMsgLevel( QString( "vectorNodes.size() = %1" ).arg( vectorNodes.size() ), 3 );
222222
if ( !vectorNodes.isEmpty() )
223223
{
224224
mErrors << tr( "Option '%1' should be configured as field" ).arg( so->key() );
@@ -309,12 +309,12 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
309309
if ( !confDomElement.isNull() )
310310
{
311311
QString optionType = confDomElement.tagName();
312-
QgsDebugMsg( "optionType = " + optionType );
312+
QgsDebugMsgLevel( "optionType = " + optionType, 3 );
313313

314314
if ( optionType == QLatin1String( "flag" ) )
315315
{
316316
QString name = confDomElement.attribute( QStringLiteral( "name" ) ).trimmed();
317-
QgsDebugMsg( "name = " + name );
317+
QgsDebugMsgLevel( "name = " + name, 3 );
318318
mFlagNames.append( name );
319319
}
320320
}
@@ -338,7 +338,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
338338
}
339339
if ( vectorInputs.size() == 1 )
340340
{
341-
QgsDebugMsg( "One input found, try to connect with column options" );
341+
QgsDebugMsgLevel( "One input found, try to connect with column options", 3 );
342342
QgsGrassModuleInput *vectorInput = vectorInputs[0];
343343
for ( QgsGrassModuleParam *param : mParams )
344344
{
@@ -347,7 +347,7 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions(
347347
{
348348
if ( !moduleField->layerInput() )
349349
{
350-
QgsDebugMsg( "Set " + vectorInput->key() + " as layer input for " + moduleField->key() );
350+
QgsDebugMsgLevel( "Set " + vectorInput->key() + " as layer input for " + moduleField->key(), 3 );
351351
moduleField->setLayerInput( vectorInput );
352352
}
353353
}
@@ -406,7 +406,7 @@ QStringList QgsGrassModuleStandardOptions::arguments()
406406
// id is not used in fact, was intended for field, but key is used instead
407407
QgsGrassModuleParam *QgsGrassModuleStandardOptions::itemByKey( QString key )
408408
{
409-
QgsDebugMsg( "key = " + key );
409+
QgsDebugMsgLevel( "key = " + key, 3 );
410410

411411
for ( int i = 0; i < mParams.size(); i++ )
412412
{
@@ -422,7 +422,7 @@ QgsGrassModuleParam *QgsGrassModuleStandardOptions::itemByKey( QString key )
422422

423423
QgsGrassModuleParam *QgsGrassModuleStandardOptions::item( QString id )
424424
{
425-
QgsDebugMsg( "id = " + id );
425+
QgsDebugMsgLevel( "id = " + id, 3 );
426426

427427
for ( int i = 0; i < mParams.size(); i++ )
428428
{
@@ -447,7 +447,7 @@ QStringList QgsGrassModuleStandardOptions::checkOutput()
447447
if ( !opt )
448448
continue;
449449

450-
QgsDebugMsg( "opt->key() = " + opt->key() );
450+
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );
451451

452452
if ( opt->isOutput() )
453453
{
@@ -517,16 +517,16 @@ void QgsGrassModuleStandardOptions::freezeOutput( bool freeze )
517517
{
518518
continue;
519519
}
520-
QgsDebugMsg( "opt->key() = " + opt->key() );
520+
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );
521521

522522
if ( opt->outputType() == QgsGrassModuleOption::Vector )
523523
{
524-
QgsDebugMsg( "freeze vector layers" );
524+
QgsDebugMsgLevel( "freeze vector layers", 3 );
525525

526526
QgsGrassObject outputObject = QgsGrass::getDefaultMapsetObject();
527527
outputObject.setName( opt->value() );
528528
outputObject.setType( QgsGrassObject::Vector );
529-
QgsDebugMsg( "outputObject = " + outputObject.toString() );
529+
QgsDebugMsgLevel( "outputObject = " + outputObject.toString(), 3 );
530530

531531
for ( QgsGrassProvider *provider : grassProviders() )
532532
{
@@ -536,25 +536,25 @@ void QgsGrassModuleStandardOptions::freezeOutput( bool freeze )
536536
{
537537
if ( freeze )
538538
{
539-
QgsDebugMsg( "freeze map " + provider->dataSourceUri() );
539+
QgsDebugMsgLevel( "freeze map " + provider->dataSourceUri(), 3 );
540540
provider->freeze();
541541
}
542542
else
543543
{
544-
QgsDebugMsg( "thaw map " + provider->dataSourceUri() );
544+
QgsDebugMsgLevel( "thaw map " + provider->dataSourceUri(), 3 );
545545
provider->thaw();
546546
}
547547
}
548548
}
549549
}
550550
else if ( opt->outputType() == QgsGrassModuleOption::Raster )
551551
{
552-
QgsDebugMsg( "freeze raster layers" );
552+
QgsDebugMsgLevel( "freeze raster layers", 3 );
553553

554554
QgsGrassObject outputObject = QgsGrass::getDefaultMapsetObject();
555555
outputObject.setName( opt->value() );
556556
outputObject.setType( QgsGrassObject::Raster );
557-
QgsDebugMsg( "outputObject = " + outputObject.toString() );
557+
QgsDebugMsgLevel( "outputObject = " + outputObject.toString(), 3 );
558558

559559
for ( QgsGrassRasterProvider *provider : grassRasterProviders() )
560560
{
@@ -564,12 +564,12 @@ void QgsGrassModuleStandardOptions::freezeOutput( bool freeze )
564564
{
565565
if ( freeze )
566566
{
567-
QgsDebugMsg( "freeze map " + provider->dataSourceUri() );
567+
QgsDebugMsgLevel( "freeze map " + provider->dataSourceUri(), 3 );
568568
provider->freeze();
569569
}
570570
else
571571
{
572-
QgsDebugMsg( "thaw map " + provider->dataSourceUri() );
572+
QgsDebugMsgLevel( "thaw map " + provider->dataSourceUri(), 3 );
573573
provider->thaw();
574574
}
575575
}
@@ -589,7 +589,7 @@ QStringList QgsGrassModuleStandardOptions::output( int type )
589589
if ( !opt )
590590
continue;
591591

592-
QgsDebugMsg( "opt->key() = " + opt->key() );
592+
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );
593593

594594
if ( opt->isOutput() )
595595
{
@@ -618,7 +618,7 @@ bool QgsGrassModuleStandardOptions::hasOutput( int type )
618618
if ( !opt )
619619
continue;
620620

621-
QgsDebugMsg( "opt->key() = " + opt->key() );
621+
QgsDebugMsgLevel( "opt->key() = " + opt->key(), 3 );
622622

623623
if ( opt->isOutput() )
624624
{
@@ -670,7 +670,7 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
670670
if ( !item )
671671
continue;
672672

673-
QgsDebugMsg( "currentMap = " + item->currentMap() );
673+
QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 );
674674
// The input may be empty, it means input is not used.
675675

676676
if ( item->currentMap().isEmpty() )
@@ -757,7 +757,7 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, QgsCo
757757
continue;
758758
}
759759

760-
QgsDebugMsg( "currentMap = " + item->currentMap() );
760+
QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 );
761761
// The input may be empty, it means input is not used.
762762
if ( item->currentMap().isEmpty() )
763763
{
@@ -827,7 +827,7 @@ bool QgsGrassModuleStandardOptions::usesRegion()
827827
return true;
828828
}
829829

830-
QgsDebugMsg( "NO usesRegion()" );
830+
QgsDebugMsgLevel( "NO usesRegion()", 2 );
831831
return false;
832832
}
833833

@@ -838,7 +838,7 @@ bool QgsGrassModuleStandardOptions::getCurrentMapRegion( QgsGrassModuleInput *in
838838
return false;
839839
}
840840

841-
QgsDebugMsg( "currentMap = " + input->currentMap() );
841+
QgsDebugMsgLevel( "currentMap = " + input->currentMap(), 3 );
842842
if ( input->currentMap().isEmpty() )
843843
{
844844
// The input may be empty, it means input is not used.
@@ -921,7 +921,7 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr
921921
// of the interface description (see https://github.com/qgis/QGIS/issues/14461)
922922
QTextCodec *codec = nullptr;
923923

924-
QgsDebugMsg( "trying to get encoding name from XML interface description..." );
924+
QgsDebugMsgLevel( "trying to get encoding name from XML interface description...", 3 );
925925

926926
// XXX: getting the encoding using a regular expression works
927927
// until GRASS will use UTF-16 or UTF-32.
@@ -932,19 +932,19 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr
932932
if ( reg.indexIn( xmlDeclaration ) != -1 )
933933
{
934934
QByteArray enc = reg.cap( 2 ).toLocal8Bit();
935-
QgsDebugMsg( QString( "found encoding name '%1'" ).arg( QString::fromUtf8( enc ) ) );
935+
QgsDebugMsgLevel( QString( "found encoding name '%1'" ).arg( QString::fromUtf8( enc ) ), 3 );
936936

937937
codec = QTextCodec::codecForName( enc );
938938
if ( !codec )
939939
{
940-
QgsDebugMsg( "unrecognized encoding name. Let's use 'System' codec" );
940+
QgsDebugMsgLevel( "unrecognized encoding name. Let's use 'System' codec", 2 );
941941
codec = QTextCodec::codecForName( "System" );
942942
Q_ASSERT( codec );
943943
}
944944
}
945945
else
946946
{
947-
QgsDebugMsg( "unable to get encoding name from XML content. Will let Qt detects encoding!" );
947+
QgsDebugMsgLevel( "unable to get encoding name from XML content. Will let Qt detects encoding!", 2 );
948948
}
949949

950950
bool ok = false;
@@ -953,11 +953,11 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr
953953

954954
if ( codec )
955955
{
956-
QgsDebugMsg( QString( "parsing XML interface description using '%1' codec..." ).arg( QString::fromUtf8( codec->name() ) ) );
956+
QgsDebugMsgLevel( QString( "parsing XML interface description using '%1' codec..." ).arg( QString::fromUtf8( codec->name() ) ), 3 );
957957
ok = gDoc.setContent( codec->toUnicode( baDesc ), false, &err, &line, &column );
958958
if ( !ok )
959959
{
960-
QgsDebugMsg( "parse FAILED. Will let Qt detects encoding" );
960+
QgsDebugMsgLevel( "parse FAILED. Will let Qt detects encoding", 2 );
961961
codec = nullptr;
962962
}
963963
}

0 commit comments

Comments
 (0)
Please sign in to comment.