Skip to content

Commit 22677dc

Browse files
committed
more log messages and auto-resize cells
1 parent 6c90891 commit 22677dc

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

src/app/qgisapp.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
580580

581581
mSplash->showMessage( tr( "QGIS Ready!" ), Qt::AlignHCenter | Qt::AlignBottom );
582582

583+
QgsMessageLog::logMessage( QgsApplication::showSettings() );
584+
583585
QgsMessageLog::logMessage( tr( "QGIS Ready!" ) );
584586

585587
mMapTipsVisible = false;
@@ -613,11 +615,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
613615
// supposedly all actions have been added, now register them to the shortcut manager
614616
QgsShortcutsManager::instance()->registerAllChildrenActions( this );
615617

616-
//finally show all the application settings as initialised above
617-
QgsDebugMsg( "\n\n\nApplication Settings:\n--------------------------\n" );
618-
QgsDebugMsg( QgsApplication::showSettings() );
619-
QgsDebugMsg( "\n--------------------------\n\n\n" );
620-
621618
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
622619
QgsApplication::setFileOpenEventReceiver( this );
623620

@@ -1755,7 +1752,7 @@ bool QgisApp::createDB()
17551752

17561753
if ( !isDbFileCopied )
17571754
{
1758-
QgsDebugMsg( "[ERROR] Can not make qgis.db private copy" );
1755+
QgsMessageLog::logMessage( tr( "[ERROR] Can not make qgis.db private copy" ) );
17591756
return false;
17601757
}
17611758
}
@@ -2332,7 +2329,7 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons
23322329
}
23332330
else
23342331
{
2335-
QgsDebugMsg(( layerPath ) + " is an invalid layer - not loaded" );
2332+
QgsMessageLog::logMessage( tr( "%1 is an invalid layer - not loaded" ).arg( layerPath ) );
23362333
QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( layerPath ) );
23372334
delete layer;
23382335
}
@@ -2928,7 +2925,7 @@ bool QgisApp::openLayer( const QString & fileName, bool allowInteractive )
29282925
if ( !ok )
29292926
{
29302927
// we have no idea what this file is...
2931-
QgsDebugMsg( "Unable to load " + fileName );
2928+
QgsMessageLog::logMessage( tr( "Unable to load %1" ).arg( fileName ) );
29322929
}
29332930

29342931
return ok;
@@ -4539,12 +4536,10 @@ void QgisApp::loadPythonSupport()
45394536
pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );
45404537
if ( !pythonlib.load() )
45414538
{
4542-
//using stderr on purpose because we want end users to see this [TS]
4543-
QgsDebugMsg( "Couldn't load Python support library: " + pythonlib.errorString() );
45444539
pythonlib.setFileName( pythonlibName );
45454540
if ( !pythonlib.load() )
45464541
{
4547-
qWarning( "Couldn't load Python support library: %s", pythonlib.errorString().toUtf8().data() );
4542+
QgsMessageLog::logMessage( tr( "Couldn't load Python support library: %1" ).arg( pythonlib.errorString() ) );
45484543
return;
45494544
}
45504545
}
@@ -4555,7 +4550,7 @@ void QgisApp::loadPythonSupport()
45554550
if ( !pythonlib_inst )
45564551
{
45574552
//using stderr on purpose because we want end users to see this [TS]
4558-
QgsDebugMsg( "Couldn't resolve python support library's instance() symbol." );
4553+
QgsMessageLog::logMessage( tr( "Couldn't resolve python support library's instance() symbol." ) );
45594554
return;
45604555
}
45614556

@@ -4570,7 +4565,7 @@ void QgisApp::loadPythonSupport()
45704565
// init python runner
45714566
QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) );
45724567

4573-
std::cout << "Python support ENABLED :-) " << std::endl; // OK
4568+
QgsMessageLog::logMessage( tr( "Python support ENABLED :-) " ) );
45744569
}
45754570
else
45764571
{

src/core/qgsapplication.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,22 +504,22 @@ void QgsApplication::exitQgis()
504504

505505
QString QgsApplication::showSettings()
506506
{
507-
QString myState = QString( "Application state:\n"
508-
"Prefix : %1\n"
509-
"Plugin Path : %2\n"
510-
"Package Data Path : %3\n"
511-
"Active Theme Name : %4\n"
512-
"Active Theme Path : %5\n"
513-
"Default Theme Path : %6\n"
514-
"SVG Search Paths : %7\n"
515-
"User DB Path : %8\n" )
507+
QString myState = tr( "Application state:\n"
508+
"Prefix:\t\t%1\n"
509+
"Plugin Path:\t\t%2\n"
510+
"Package Data Path:\t%3\n"
511+
"Active Theme Name:\t%4\n"
512+
"Active Theme Path:\t%5\n"
513+
"Default Theme Path:\t%6\n"
514+
"SVG Search Paths:\t%7\n"
515+
"User DB Path:\t%8\n" )
516516
.arg( mPrefixPath )
517517
.arg( mPluginPath )
518518
.arg( mPkgDataPath )
519519
.arg( themeName() )
520520
.arg( activeThemePath() )
521521
.arg( defaultThemePath() )
522-
.arg( svgPaths().join( "\n" ) )
522+
.arg( svgPaths().join( "\n\t\t" ) )
523523
.arg( qgisMasterDbFilePath() );
524524
return myState;
525525
}

src/core/qgsmessagelog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
***************************************************************************/
1515

1616
#include "qgsmessagelog.h"
17+
#include <qgslogger.h>
18+
#include <QDateTime>
1719
#include <iostream>
1820

1921
class QgsMessageLogConsole;
@@ -27,6 +29,8 @@ void QgsMessageLog::setLogger( void (*f)( QString message, QString tag, int leve
2729

2830
void QgsMessageLog::logMessage( QString message, QString tag, int level )
2931
{
32+
QgsDebugMsg( QString( "%1 %2[%3] %4" ).arg( QDateTime::currentDateTime().toString( Qt::ISODate ) ).arg( tag ).arg( level ).arg( message ) );
33+
3034
if( !gmLogger )
3135
QgsMessageLogConsole::logger( message, tag, level );
3236
else

src/gui/qgsmessagelogviewer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "qgsmessagelogviewer.h"
1919
#include "qgsmessagelog.h"
20-
#include "qgslogger.h"
2120

2221
#include <QSettings>
2322
#include <QTableWidget>
@@ -66,25 +65,23 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )
6665
{
6766
w = new QTableWidget( 0, 3, this );
6867
w->verticalHeader()->setDefaultSectionSize( 16 );
68+
w->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents );
6969
w->verticalHeader()->setVisible( false );
7070
w->setGridStyle( Qt::DotLine );
7171
w->setEditTriggers( QAbstractItemView::NoEditTriggers );
7272
w->setHorizontalHeaderLabels( QStringList() << tr( "Timestamp" ) << tr( "Message" ) << tr( "Level" ) );
73+
w->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
7374
tabWidget->addTab( w, tag );
7475
}
7576

7677
int n = w->rowCount();
7778

78-
QgsDebugMsg( QString( "%1: %2[%3] %4" ).arg( n ).arg( QDateTime::currentDateTime().toString( Qt::ISODate ) ).arg( level ).arg( level ) );
79-
8079
w->setRowCount( n + 1 );
8180
QTableWidgetItem *item = new QTableWidgetItem( QDateTime::currentDateTime().toString( Qt::ISODate ) );
8281
w->setItem( n, 0, item );
8382
w->setItem( n, 1, new QTableWidgetItem( message ) );
8483
w->setItem( n, 2, new QTableWidgetItem( QString::number( level ) ) );
85-
w->scrollToItem( item );
86-
87-
w->resizeColumnsToContents();
84+
w->scrollToBottom();
8885
}
8986

9087
void QgsMessageLogViewer::closeTab( int index )

0 commit comments

Comments
 (0)