Skip to content

Commit 6c90891

Browse files
committed
use the same format in logfile and on console and use either console or logfile
1 parent bae8301 commit 6c90891

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/core/qgslogger.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,35 @@ void QgsLogger::debug( const QString& msg, int debuglevel, const char* file, con
3636
int dlevel = debugLevel();
3737
if ( dlevel >= debuglevel && debuglevel > 0 )
3838
{
39-
if ( file == NULL )
39+
QString m;
40+
41+
if ( !file )
4042
{
41-
qDebug( "%s", msg.toLocal8Bit().constData() );
42-
logMessageToFile( msg );
43+
m = msg;
4344
}
44-
else if ( function == NULL )
45+
else if ( !function )
4546
{
46-
qDebug( "%s: %s", file, msg.toLocal8Bit().constData() );
47-
logMessageToFile( msg );
47+
m = QString( "%1: %2" ).arg( file ).arg( msg );
4848
}
4949
else if ( line == -1 )
5050
{
51-
qDebug( "%s: (%s) %s", file, function, msg.toLocal8Bit().constData() );
52-
logMessageToFile( msg );
51+
m = QString( "%1: (%2) %3" ).arg( file ).arg( function ).arg( msg );
5352
}
5453
else
5554
{
5655
#ifndef _MSC_VER
57-
qDebug( "%s: %d: (%s) %s", file, line, function, msg.toLocal8Bit().constData() );
56+
m = QString( "%1: %2: (%3) %4" ).arg( file ).arg( line ).arg( function ).arg( msg );
5857
#else
59-
qDebug( "%s(%d) : (%s) %s", file, line, function, msg.toLocal8Bit().constData() );
58+
m = QString( "%1(%2) : (%3) %4" ).arg( file ).arg( line ).arg( function ).arg( msg );
6059
#endif
61-
logMessageToFile( msg );
60+
}
61+
if ( logFile().isEmpty() )
62+
{
63+
qDebug( "%s", m.toLocal8Bit().constData() );
64+
}
65+
else
66+
{
67+
logMessageToFile( m );
6268
}
6369
}
6470
}

0 commit comments

Comments
 (0)