From e3bb4c9b14b2533e70a05e029c8c2b4afb50d860 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 6 Nov 2011 07:55:06 +0100 Subject: [PATCH] * CrashReporter now also sends Tomahawk.log and the proper version number to our breakpad server. --- src/breakpad/CrashReporter/CMakeLists.txt | 4 ++-- src/breakpad/CrashReporter/CrashReporter.cpp | 25 +++++++++++--------- src/libtomahawk/utils/logger.cpp | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/breakpad/CrashReporter/CMakeLists.txt b/src/breakpad/CrashReporter/CMakeLists.txt index 02dfedf1e..8b019947b 100644 --- a/src/breakpad/CrashReporter/CMakeLists.txt +++ b/src/breakpad/CrashReporter/CMakeLists.txt @@ -13,8 +13,8 @@ QT4_WRAP_UI( crashreporter_UI_HEADERS ${crashreporter_UI} ) QT4_ADD_RESOURCES( crashreporter_RC_RCC ${crashreporter_RC} ) INCLUDE( ${QT_USE_FILE} ) -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ../../libtomahawk ) ADD_DEFINITIONS( ${QT_DEFINITIONS} ) ADD_EXECUTABLE( CrashReporter ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} ) -TARGET_LINK_LIBRARIES( CrashReporter ${QT_LIBRARIES} ) +TARGET_LINK_LIBRARIES( CrashReporter ${QT_LIBRARIES} tomahawklib ) diff --git a/src/breakpad/CrashReporter/CrashReporter.cpp b/src/breakpad/CrashReporter/CrashReporter.cpp index 468e6a4ed..15e563529 100644 --- a/src/breakpad/CrashReporter/CrashReporter.cpp +++ b/src/breakpad/CrashReporter/CrashReporter.cpp @@ -25,6 +25,9 @@ #include #include +#include "utils/tomahawkutils.h" + +#define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit() #define RESPATH ":/data/" @@ -40,7 +43,6 @@ CrashReporter::CrashReporter( const QStringList& args ) ui.progressLabel->setPalette( Qt::gray ); #ifdef Q_WS_MAC - // macify++ QFont f = ui.bottomLabel->font(); f.setPointSize( 10 ); ui.bottomLabel->setFont( f ); @@ -55,12 +57,14 @@ CrashReporter::CrashReporter( const QStringList& args ) ui.bottomLabel->setIndent( 1 ); // adjust the spacer since we adjusted the spacing above - for (int x = 0; x < ui.vboxLayout->count(); ++x) - if (QSpacerItem* spacer = ui.vboxLayout->itemAt( x )->spacerItem()) + for ( int x = 0; x < ui.vboxLayout->count(); ++x ) + { + if ( QSpacerItem* spacer = ui.vboxLayout->itemAt( x )->spacerItem() ) { spacer->changeSize( 6, 2, QSizePolicy::Minimum, QSizePolicy::Fixed ); break; } + } #endif //Q_WS_MAC m_http = new QHttp( "oops.tomahawk-player.org", 80, this ); @@ -72,9 +76,9 @@ CrashReporter::CrashReporter( const QStringList& args ) m_minidump = m_dir + '/' + args.value( 2 ) + ".dmp"; m_product_name = args.value( 3 ); - QTimer::singleShot( 0, this, SLOT(send()) ); - setFixedSize( sizeHint() ); + + QTimer::singleShot( 0, this, SLOT( send() ) ); } @@ -94,7 +98,7 @@ CrashReporter::send() // socorro expects a 10 digit build id QRegExp rx( "(\\d+\\.\\d+\\.\\d+).(\\d+)" ); - rx.exactMatch( "0.2.99" ); + rx.exactMatch( TomahawkUtils::appFriendlyVersion() ); QString const version = rx.cap( 1 ); QString const buildId = rx.cap( 2 ).leftJustified( 10, '0' ); @@ -103,7 +107,7 @@ CrashReporter::send() QList pairs; pairs << Pair( "BuildID", buildId.toUtf8() ) << Pair( "ProductName", m_product_name.toUtf8() ) - << Pair( "Version", version.toUtf8() ) + << Pair( "Version", TomahawkUtils::appFriendlyVersion().toLocal8Bit() ) << Pair( "Vendor", "Tomahawk" ) << Pair( "timestamp", QByteArray::number( QDateTime::currentDateTime().toTime_t() ) ); @@ -126,14 +130,13 @@ CrashReporter::send() // add logfile body += "--thkboundary\r\n"; - body += "Content-Disposition: form-data; name=\"upload_file_containerlog\"; filename=\"container.log\"\r\n"; + body += "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n"; body += "Content-Type: application/x-gzip\r\n"; body += "\r\n"; -// body += qCompress( contents( "Tomahawk.log" ) ); + body += qCompress( contents( LOGFILE ) ); body += "\r\n"; body += "--thkboundary--\r\n"; -////// QHttpRequestHeader header( "POST", "/addreport.php" ); header.setContentType( "multipart/form-data; boundary=thkboundary" ); header.setValue( "HOST", "oops.tomahawk-player.org" ); @@ -179,5 +182,5 @@ CrashReporter::onFail( int error, const QString& errorString ) { ui.button->setText( tr( "Close" ) ); ui.progressLabel->setText( tr( "Failed to send crash info." ) ); - qDebug() << "Error: " << error << errorString; + qDebug() << "Error:" << error << errorString; } diff --git a/src/libtomahawk/utils/logger.cpp b/src/libtomahawk/utils/logger.cpp index 846e2586b..ea7c3bada 100644 --- a/src/libtomahawk/utils/logger.cpp +++ b/src/libtomahawk/utils/logger.cpp @@ -31,7 +31,7 @@ #include "utils/tomahawkutils.h" #define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit() -#define LOGFILE_SIZE 1024 * 512 +#define LOGFILE_SIZE 1024 * 256 #define RELEASE_LEVEL_THRESHOLD 0 #define DEBUG_LEVEL_THRESHOLD LOGEXTRA