Skip to content

Commit 55a8cdd

Browse files
author
mhugent
committed
made QgsLogger less verbose, replaced some std::couts in QgsRasterLayer
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5180 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3c97c9a commit 55a8cdd

File tree

4 files changed

+226
-316
lines changed

4 files changed

+226
-316
lines changed

src/core/qgslogger.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ void QgsLogger::debug(const QString& msg, int debuglevel, const char* file, cons
3838
}
3939
else if(function == NULL)
4040
{
41-
qDebug("File: %s, Message: %s", file, msg.toLocal8Bit().data());
41+
qDebug("%s: %s", file, msg.toLocal8Bit().data());
4242
}
4343
else if(line == -1)
4444
{
45-
qDebug("File: %s, Function: %s, Message: %s", file, function, msg.toLocal8Bit().data());
45+
qDebug("%s: (%s) %s", file, function, msg.toLocal8Bit().data());
4646
}
4747
else
4848
{
49-
qDebug("File: %s, Function: %s, Line: %d, Message: %s", file, function, line, msg.toLocal8Bit().data());
49+
qDebug("%s: %d: (%s) %s", file, line, function, msg.toLocal8Bit().data());
5050
}
5151
}
5252
}
@@ -67,19 +67,19 @@ void QgsLogger::debug(const QString& var, int val, int debuglevel, const char* f
6767
{
6868
if(file == NULL)
6969
{
70-
qDebug("Variable: %s, Value: %d", var.toLocal8Bit().data(), val);
70+
qDebug("%s: %d", var.toLocal8Bit().data(), val);
7171
}
7272
else if(function == NULL)
7373
{
74-
qDebug("File: %s, Variable: %s, Value: %d", file, var.toLocal8Bit().data(), val);
74+
qDebug("%s: %s: %d", file, var.toLocal8Bit().data(), val);
7575
}
7676
else if(line == -1)
7777
{
78-
qDebug("File: %s, Function: %s, Variable: %s, Value: %d", file, function, var.toLocal8Bit().data(), val);
78+
qDebug("%s: (%s): %s: %d", file, function, var.toLocal8Bit().data(), val);
7979
}
8080
else
8181
{
82-
qDebug("File: %s, Function: %s, Line: %d, Variable: %s, Value: %d", file, function, line, var.toLocal8Bit().data(), val);
82+
qDebug("%s: %d: (%s), %s: %d", file, line, function, var.toLocal8Bit().data(), val);
8383
}
8484
}
8585
}
@@ -100,19 +100,19 @@ void QgsLogger::debug(const QString& var, double val, int debuglevel, const char
100100
{
101101
if(file == NULL)
102102
{
103-
qDebug("Variable: %s, Value: %f", var.toLocal8Bit().data(), val);
103+
qDebug("%s: %f", var.toLocal8Bit().data(), val);
104104
}
105105
else if(function == NULL)
106106
{
107-
qDebug("File: %s, Variable: %s, Value: %f", file, var.toLocal8Bit().data(), val);
107+
qDebug("%s: %s: %f", file, var.toLocal8Bit().data(), val);
108108
}
109109
else if(line == -1)
110110
{
111-
qDebug("File: %s, Function: %s, Variable: %s, Value: %f", file, function, var.toLocal8Bit().data(), val);
111+
qDebug("%s: (%s): %s: %f", file, function, var.toLocal8Bit().data(), val);
112112
}
113113
else
114114
{
115-
qDebug("File: %s, Function: %s, Line: %d, Variable: %s, Value: %f", file, function, line, var.toLocal8Bit().data(), val);
115+
qDebug("%s: %d: (%s), %s: %d", file, line, function, var.toLocal8Bit().data(), val);
116116
}
117117
}
118118
}

src/core/qgslogger.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ class QgsLogger
7272
os << var.toLocal8Bit().data() << " = " << val;
7373
if(line == -1)
7474
{
75-
qDebug("File: %s\nFunction: %s\nMessage: %s",
76-
file, function, os.str().c_str());
75+
qDebug("%s: (%s) %s", file, function, os.str().c_str());
7776
}
7877
else
7978
{
80-
qDebug("File: %s\nFunction: %s\nLine: %s\nMessage: %s", file, function, \
81-
QString::number(line).toLocal8Bit().data(), os.str().c_str());
79+
qDebug("%s: %d: (%s) %s", file, line, function, os.str().c_str());
8280
}
8381
}
8482

src/gui/qgsmaplayer.cpp

+15-31
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <QMenu>
3232

3333
#include "qgisapp.h"
34+
#include "qgslogger.h"
3435
#include "qgsmaptopixel.h"
3536
#include "qgsrect.h"
3637
#include "qgsproject.h"
@@ -58,16 +59,11 @@ QgsMapLayer::QgsMapLayer(int type,
5859
m_visible(true)
5960

6061
{
61-
#ifdef QGISDEBUG
62-
std::cout << "QgsMapLayer::QgsMapLayer - lyrname is '" << lyrname.toLocal8Bit().data() << "'."<< std::endl;
63-
#endif
62+
QgsDebugMsg("QgsMapLayer::QgsMapLayer - lyrname is '" + lyrname);
6463

6564
// Set the display name = internal name
6665
layerName = internalName;
67-
68-
#ifdef QGISDEBUG
69-
std::cout << "QgsMapLayer::QgsMapLayer - layerName is '" << layerName.toLocal8Bit().data() << "'."<< std::endl;
70-
#endif
66+
QgsDebugMsg("QgsMapLayer::QgsMapLayer - layerName is '" + layerName);
7167

7268
// Generate the unique ID of this layer
7369
QDateTime dt = QDateTime::currentDateTime();
@@ -84,9 +80,6 @@ QgsMapLayer::QgsMapLayer(int type,
8480
mMinScale = 0;
8581
mMaxScale = 100000000;
8682
mScaleBasedVisibility = false;
87-
88-
89-
9083
}
9184

9285

@@ -110,19 +103,15 @@ QString const & QgsMapLayer::getLayerID() const
110103
/** Write property of QString layerName. */
111104
void QgsMapLayer::setLayerName(const QString & _newVal)
112105
{
113-
#ifdef QGISDEBUG
114-
std::cout << "QgsMapLayer::setLayerName: new name is '" << _newVal.toLocal8Bit().data() << "'."<< std::endl;
115-
#endif
116-
layerName = _newVal;
106+
QgsDebugMsg("QgsMapLayer::setLayerName: new name is '" + _newVal);
107+
layerName = _newVal;
117108
}
118109

119110
/** Read property of QString layerName. */
120111
QString const & QgsMapLayer::name() const
121112
{
122-
#ifdef QGISDEBUG
123-
std::cout << "QgsMapLayer::name: returning name '" << layerName.toLocal8Bit().data() << "'."<< std::endl;
124-
#endif
125-
return layerName;
113+
QgsDebugMsg("QgsMapLayer::name: returning name '" + layerName);
114+
return layerName;
126115
}
127116

128117
QString const & QgsMapLayer::source() const
@@ -464,9 +453,7 @@ void QgsMapLayer::updateItemPixmap()
464453

465454
void QgsMapLayer::invalidTransformInput()
466455
{
467-
#ifdef QGISDEBUG
468-
std::cout << " QgsMapLayer::invalidTransformInput() called" << std::endl;
469-
#endif
456+
QgsLogger::warning("QgsMapLayer::invalidTransformInput() called");
470457
if (mLegendLayerFile) // XXX should we know about our legend?
471458
{
472459
QPixmap pix=mLegendLayerFile->getOriginalPixmap();
@@ -518,9 +505,7 @@ QString QgsMapLayer::errorString()
518505

519506
void QgsMapLayer::connectNotify( const char * signal )
520507
{
521-
#ifdef QGISDEBUG
522-
std::cerr << "QgsMapLayer connected to " << signal << "\n";
523-
#endif
508+
QgsDebugMsg("QgsMapLayer connected to " + QString(signal));
524509
} // QgsMapLayer::connectNotify
525510

526511

@@ -561,14 +546,14 @@ void QgsMapLayer::keyPressed ( QKeyEvent * e )
561546
QgsCoordinateTransform * QgsMapLayer::coordinateTransform()
562547
{
563548
#ifdef QGISDEBUG
564-
std::cout << "Maplayer asked for coordinateTransform which is...." ;
549+
QgsDebugMsg("Maplayer asked for coordinateTransform which is....");
565550
if (!mCoordinateTransform)
566551
{
567-
std::cout << "*NOT* valid" << std::endl;
552+
QgsDebugMsg("*NOT* valid");
568553
}
569554
else
570555
{
571-
std::cout << "valid" << std::endl;
556+
QgsDebugMsg("valid");
572557
}
573558

574559
#endif
@@ -597,8 +582,8 @@ bool QgsMapLayer::projectExtent(QgsRect& extent, QgsRect& r2)
597582
try
598583
{
599584
#ifdef QGISDEBUG
600-
std::cerr << "Getting extent of canvas in layers CS. Canvas is "
601-
<< extent << '\n';
585+
QgsLogger::debug<QgsRect>("Getting extent of canvas in layers CS. Canvas is ", extent, __FILE__,\
586+
__FUNCTION__, __LINE__);
602587
#endif
603588
// Split the extent into two if the source SRS is
604589
// geographic and the extent crosses the split in
@@ -633,8 +618,7 @@ bool QgsMapLayer::projectExtent(QgsRect& extent, QgsRect& r2)
633618
}
634619
catch (QgsCsException &cse)
635620
{
636-
qDebug( "Transform error caught in %s line %d:\n%s",
637-
__FILE__, __LINE__, cse.what());
621+
QgsLogger::warning("Transform error caught in " + QString(__FILE__) + ", line " + QString::number(__LINE__));
638622
extent = QgsRect(-DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX);
639623
r2 = QgsRect(-DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX);
640624
}

0 commit comments

Comments
 (0)