Skip to content

Commit

Permalink
Log to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jan 20, 2020
1 parent 0bf5de0 commit 34b278e
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/server/qgis_mapserver.cpp
Expand Up @@ -135,20 +135,19 @@ int main( int argc, char *argv[] )

if ( ! tcpServer.listen( address, serverPort.toInt( ) ) )
{
QgsMessageLog::logMessage( QObject::tr( "Unable to start the server: %1." )
.arg( tcpServer.errorString() ) );
std::cerr << QObject::tr( "Unable to start the server: %1." )
.arg( tcpServer.errorString() ).toStdString();
tcpServer.close();
}
else
{

const int port { tcpServer.serverPort() };
QgsMessageLog::logMessage( QObject::tr( "QGIS Development Server listening on http://%1:%2" )
.arg( ipAddress ).arg( port ),
QStringLiteral( "QGIS Development Server" ), Qgis::Info );
std::cout << QObject::tr( "QGIS Development Server listening on http://%1:%2" )
.arg( ipAddress ).arg( port ).toStdString() << std::endl;

#ifndef Q_OS_WIN
QgsMessageLog::logMessage( QObject::tr( "CTRL+C to exit" ) );
std::cout << QObject::tr( "CTRL+C to exit" ).toStdString() << std::endl;
#endif

static const QMap<int, QString> knownStatuses
Expand Down Expand Up @@ -301,14 +300,13 @@ int main( int argc, char *argv[] )
clientConnection->write( body );

// 10.185.248.71 [09/Jan/2015:19:12:06 +0000] 808840 <time> "GET / HTTP/1.1" 500"
QgsMessageLog::logMessage( QStringLiteral( "%1 [%2] %3 %4ms \"%5\" %6" )
.arg( clientConnection->peerAddress().toString() )
.arg( QDateTime::currentDateTime().toString() )
.arg( body.size() )
.arg( std::chrono::duration_cast<std::chrono::milliseconds>( elapsedTime ).count() )
.arg( firstLinePieces.join( ' ' ) )
.arg( response.statusCode() ),
QStringLiteral( "QGIS Development Server" ), Qgis::Info );
std::cout << QStringLiteral( "%1 [%2] %3 %4ms \"%5\" %6" )
.arg( clientConnection->peerAddress().toString() )
.arg( QDateTime::currentDateTime().toString() )
.arg( body.size() )
.arg( std::chrono::duration_cast<std::chrono::milliseconds>( elapsedTime ).count() )
.arg( firstLinePieces.join( ' ' ) )
.arg( response.statusCode() ).toStdString() << std::endl;

}
catch ( HttpException &ex )
Expand All @@ -319,11 +317,10 @@ int main( int argc, char *argv[] )
clientConnection->write( "\r\n" );
clientConnection->write( ex.message().toUtf8() );

QgsMessageLog::logMessage( QStringLiteral( "%1 [%2] \"%3\" - - 500" )
.arg( clientConnection->peerAddress().toString() )
.arg( QDateTime::currentDateTime().toString() )
.arg( ex.message() ),
QStringLiteral( "QGIS Development Server" ), Qgis::Info );
std::cout << QStringLiteral( "%1 [%2] \"%3\" - - 500" )
.arg( clientConnection->peerAddress().toString() )
.arg( QDateTime::currentDateTime().toString() )
.arg( ex.message() ).toStdString() << std::endl;

}
clientConnection->disconnectFromHost();
Expand Down

0 comments on commit 34b278e

Please sign in to comment.