Add a new logging system

This commit is contained in:
David Sansome 2011-04-22 16:50:29 +00:00
parent 93eb4dea3f
commit 3eedc916ad
81 changed files with 588 additions and 280 deletions

View File

@ -73,6 +73,7 @@ set(SOURCES
core/globalshortcutbackend.cpp core/globalshortcutbackend.cpp
core/globalshortcuts.cpp core/globalshortcuts.cpp
core/gnomeglobalshortcutbackend.cpp core/gnomeglobalshortcutbackend.cpp
core/logging.cpp
core/mergedproxymodel.cpp core/mergedproxymodel.cpp
core/musicstorage.cpp core/musicstorage.cpp
core/network.cpp core/network.cpp

View File

@ -21,6 +21,7 @@
#include "boomanalyzer.h" #include "boomanalyzer.h"
#include "sonogram.h" #include "sonogram.h"
#include "turbine.h" #include "turbine.h"
#include "core/logging.h"
#include <QMouseEvent> #include <QMouseEvent>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -136,7 +137,7 @@ void AnalyzerContainer::ChangeAnalyzer(int id) {
QObject* instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this)); QObject* instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this));
if (!instance) { if (!instance) {
qWarning() << "Couldn't intialise a new" << analyzer_types_[id]->className(); qLog(Warning) << "Couldn't intialise a new" << analyzer_types_[id]->className();
return; return;
} }

View File

@ -45,7 +45,6 @@ BarAnalyzer::BarAnalyzer( QWidget *parent )
void BarAnalyzer::resizeEvent( QResizeEvent * e ) void BarAnalyzer::resizeEvent( QResizeEvent * e )
{ {
qDebug() << "Baranalyzer Resized(" << width() << "x" << height() << ")";
init(); init();
} }
@ -61,8 +60,6 @@ void BarAnalyzer::init()
MAX_DOWN = int(0 -(qMax(1, height() / 50))); MAX_DOWN = int(0 -(qMax(1, height() / 50)));
MAX_UP = int(qMax(1, height() / 25)); MAX_UP = int(qMax(1, height() / 25));
qDebug() << "BAND_COUNT = " << BAND_COUNT << " MAX_UP = " << MAX_UP << "MAX_DOWN = " << MAX_DOWN;
barVector.resize( BAND_COUNT, 0 ); barVector.resize( BAND_COUNT, 0 );
roofVector.resize( BAND_COUNT, height() -5 ); roofVector.resize( BAND_COUNT, height() -5 );
roofVelocityVector.resize( BAND_COUNT, ROOF_VELOCITY_REDUCTION_FACTOR ); roofVelocityVector.resize( BAND_COUNT, ROOF_VELOCITY_REDUCTION_FACTOR );

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include "commandlineoptions.h" #include "commandlineoptions.h"
#include "logging.h"
#include <cstdlib> #include <cstdlib>
#include <getopt.h> #include <getopt.h>
@ -48,7 +49,10 @@ const char* CommandlineOptions::kHelpText =
"\n" "\n"
"%20:\n" "%20:\n"
" -o, --show-osd %21\n" " -o, --show-osd %21\n"
" -g, --language <lang> %22\n"; " -g, --language <lang> %22\n"
" --quiet %23\n"
" --verbose %24\n"
" --log-levels <levels> %25\n";
CommandlineOptions::CommandlineOptions(int argc, char** argv) CommandlineOptions::CommandlineOptions(int argc, char** argv)
@ -62,7 +66,8 @@ CommandlineOptions::CommandlineOptions(int argc, char** argv)
seek_by_(0), seek_by_(0),
play_track_at_(-1), play_track_at_(-1),
show_osd_(false), show_osd_(false),
stun_test_(StunTestNone) stun_test_(StunTestNone),
log_levels_(logging::kDefaultLogLevels)
{ {
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
// Remove -psn_xxx option that Mac passes when opened from Finder. // Remove -psn_xxx option that Mac passes when opened from Finder.
@ -108,6 +113,9 @@ bool CommandlineOptions::Parse() {
{"show-osd", no_argument, 0, 'o'}, {"show-osd", no_argument, 0, 'o'},
{"language", required_argument, 0, 'g'}, {"language", required_argument, 0, 'g'},
{"quiet", no_argument, 0, Quiet},
{"verbose", no_argument, 0, Verbose},
{"log-levels", required_argument, 0, LogLevels},
{"stun-test", required_argument, 0, 'z'}, {"stun-test", required_argument, 0, 'z'},
@ -144,24 +152,30 @@ bool CommandlineOptions::Parse() {
tr("Play the <n>th track in the playlist"), tr("Play the <n>th track in the playlist"),
tr("Other options"), tr("Other options"),
tr("Display the on-screen-display"), tr("Display the on-screen-display"),
tr("Change the language")); tr("Change the language"),
tr("Equivalent to --log-levels *:1"),
tr("Equivalent to --log-levels *:3"),
tr("Comma separated list of class:level, level is 0-3"));
std::cout << translated_help_text.toLocal8Bit().constData(); std::cout << translated_help_text.toLocal8Bit().constData();
return false; return false;
} }
case 'p': player_action_ = Player_Play; break; case 'p': player_action_ = Player_Play; break;
case 't': player_action_ = Player_PlayPause; break; case 't': player_action_ = Player_PlayPause; break;
case 'u': player_action_ = Player_Pause; break; case 'u': player_action_ = Player_Pause; break;
case 's': player_action_ = Player_Stop; break; case 's': player_action_ = Player_Stop; break;
case 'r': player_action_ = Player_Previous; break; case 'r': player_action_ = Player_Previous; break;
case 'f': player_action_ = Player_Next; break; case 'f': player_action_ = Player_Next; break;
case 'a': url_list_action_ = UrlList_Append; break; case 'a': url_list_action_ = UrlList_Append; break;
case 'l': url_list_action_ = UrlList_Load; break; case 'l': url_list_action_ = UrlList_Load; break;
case 'o': show_osd_ = true; break; case 'o': show_osd_ = true; break;
case 'g': language_ = QString(optarg); break; case 'g': language_ = QString(optarg); break;
case VolumeUp: volume_modifier_ = +4; break; case VolumeUp: volume_modifier_ = +4; break;
case VolumeDown: volume_modifier_ = -4; break; case VolumeDown: volume_modifier_ = -4; break;
case Quiet: log_levels_ = "1"; break;
case Verbose: log_levels_ = "3"; break;
case LogLevels: log_levels_ = QString(optarg); break;
case 'v': case 'v':
set_volume_ = QString(optarg).toInt(&ok); set_volume_ = QString(optarg).toInt(&ok);
@ -252,7 +266,8 @@ QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a) {
<< a.seek_by_ << a.seek_by_
<< a.play_track_at_ << a.play_track_at_
<< a.show_osd_ << a.show_osd_
<< a.urls_; << a.urls_
<< a.log_levels_;
return s; return s;
} }
@ -268,7 +283,8 @@ QDataStream& operator>>(QDataStream& s, CommandlineOptions& a) {
>> a.seek_by_ >> a.seek_by_
>> a.play_track_at_ >> a.play_track_at_
>> a.show_osd_ >> a.show_osd_
>> a.urls_; >> a.urls_
>> a.log_levels_;
a.player_action_ = CommandlineOptions::PlayerAction(player_action); a.player_action_ = CommandlineOptions::PlayerAction(player_action);
a.url_list_action_ = CommandlineOptions::UrlListAction(url_list_action); a.url_list_action_ = CommandlineOptions::UrlListAction(url_list_action);

View File

@ -66,6 +66,7 @@ class CommandlineOptions {
bool show_osd() const { return show_osd_; } bool show_osd() const { return show_osd_; }
QList<QUrl> urls() const { return urls_; } QList<QUrl> urls() const { return urls_; }
QString language() const { return language_; } QString language() const { return language_; }
QString log_levels() const { return log_levels_; }
StunTestDirection stun_test() const { return stun_test_; } StunTestDirection stun_test() const { return stun_test_; }
@ -81,6 +82,9 @@ class CommandlineOptions {
VolumeDown, VolumeDown,
SeekTo, SeekTo,
SeekBy, SeekBy,
Quiet,
Verbose,
LogLevels,
}; };
QString tr(const char* source_text); QString tr(const char* source_text);
@ -102,6 +106,7 @@ class CommandlineOptions {
bool show_osd_; bool show_osd_;
QString language_; QString language_;
StunTestDirection stun_test_; StunTestDirection stun_test_;
QString log_levels_;
QList<QUrl> urls_; QList<QUrl> urls_;
}; };

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include "crashreporting.h" #include "crashreporting.h"
#include "core/logging.h"
#include <QApplication> #include <QApplication>
#include <QDir> #include <QDir>
@ -106,7 +107,7 @@ CrashSender::CrashSender(const QString& path)
bool CrashSender::Start() { bool CrashSender::Start() {
if (!file_->open(QIODevice::ReadOnly)) { if (!file_->open(QIODevice::ReadOnly)) {
qWarning() << "Failed to open crash report" << path_; qLog(Warning) << "Failed to open crash report" << path_;
return false; return false;
} }

View File

@ -19,6 +19,7 @@
#include "database.h" #include "database.h"
#include "scopedtransaction.h" #include "scopedtransaction.h"
#include "utilities.h" #include "utilities.h"
#include "core/logging.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
@ -237,7 +238,7 @@ void Database::StaticInit() {
QLibrary library(plugin_path); QLibrary library(plugin_path);
if (!library.load()) { if (!library.load()) {
qDebug() << "QLibrary::load() failed for " << plugin_path; qLog(Error) << "QLibrary::load() failed for " << plugin_path;
return; return;
} }
@ -260,7 +261,7 @@ void Database::StaticInit() {
!_sqlite3_value_text || !_sqlite3_value_text ||
!_sqlite3_result_int64 || !_sqlite3_result_int64 ||
!_sqlite3_user_data) { !_sqlite3_user_data) {
qDebug() << "Couldn't resolve sqlite symbols"; qLog(Error) << "Couldn't resolve sqlite symbols";
sLoadedSqliteSymbols = false; sLoadedSqliteSymbols = false;
} else { } else {
sLoadedSqliteSymbols = true; sLoadedSqliteSymbols = true;
@ -384,7 +385,7 @@ QSqlDatabase Database::Connect() {
set_fts_tokenizer.bindValue(":pointer", QByteArray( set_fts_tokenizer.bindValue(":pointer", QByteArray(
reinterpret_cast<const char*>(&sFTSTokenizer), sizeof(&sFTSTokenizer))); reinterpret_cast<const char*>(&sFTSTokenizer), sizeof(&sFTSTokenizer)));
if (!set_fts_tokenizer.exec()) { if (!set_fts_tokenizer.exec()) {
qWarning() << "Couldn't register FTS3 tokenizer"; qLog(Warning) << "Couldn't register FTS3 tokenizer";
} }
// We want Unicode aware LIKE clauses and FTS if possible. // We want Unicode aware LIKE clauses and FTS if possible.
@ -456,7 +457,7 @@ void Database::UpdateMainSchema(QSqlDatabase* db) {
startup_schema_version_ = schema_version; startup_schema_version_ = schema_version;
if (schema_version > kSchemaVersion) { if (schema_version > kSchemaVersion) {
qWarning() << "The database schema (version" << schema_version << ") is newer than I was expecting"; qLog(Warning) << "The database schema (version" << schema_version << ") is newer than I was expecting";
return; return;
} }
if (schema_version < kSchemaVersion) { if (schema_version < kSchemaVersion) {
@ -469,7 +470,7 @@ void Database::UpdateMainSchema(QSqlDatabase* db) {
void Database::RecreateAttachedDb(const QString& database_name) { void Database::RecreateAttachedDb(const QString& database_name) {
if (!attached_databases_.contains(database_name)) { if (!attached_databases_.contains(database_name)) {
qWarning() << "Attached database does not exist:" << database_name; qLog(Warning) << "Attached database does not exist:" << database_name;
return; return;
} }
@ -482,12 +483,12 @@ void Database::RecreateAttachedDb(const QString& database_name) {
QSqlQuery q("DETACH DATABASE :alias", db); QSqlQuery q("DETACH DATABASE :alias", db);
q.bindValue(":alias", database_name); q.bindValue(":alias", database_name);
if (!q.exec()) { if (!q.exec()) {
qWarning() << "Failed to detach database" << database_name; qLog(Warning) << "Failed to detach database" << database_name;
return; return;
} }
if (!QFile::remove(filename)) { if (!QFile::remove(filename)) {
qWarning() << "Failed to remove file" << filename; qLog(Warning) << "Failed to remove file" << filename;
} }
} }
@ -533,7 +534,7 @@ void Database::ExecCommands(const QString &schema, QSqlDatabase &db) {
// in the schema files to update all songs tables at once. // in the schema files to update all songs tables at once.
if (command.contains(kMagicAllSongsTables)) { if (command.contains(kMagicAllSongsTables)) {
foreach (const QString& table, tables) { foreach (const QString& table, tables) {
qDebug() << "Updating" << table << "for" << kMagicAllSongsTables; qLog(Info) << "Updating" << table << "for" << kMagicAllSongsTables;
QString new_command(command); QString new_command(command);
new_command.replace(kMagicAllSongsTables, table); new_command.replace(kMagicAllSongsTables, table);
QSqlQuery query(db.exec(new_command)); QSqlQuery query(db.exec(new_command));
@ -575,9 +576,9 @@ QStringList Database::SongsTables(QSqlDatabase& db) const {
bool Database::CheckErrors(const QSqlQuery& query) { bool Database::CheckErrors(const QSqlQuery& query) {
QSqlError last_error = query.lastError(); QSqlError last_error = query.lastError();
if (last_error.isValid()) { if (last_error.isValid()) {
qDebug() << "db error: " << last_error; qLog(Error) << "db error: " << last_error;
qDebug() << "faulty query: " << query.lastQuery(); qLog(Error) << "faulty query: " << query.lastQuery();
qDebug() << "bound values: " << query.boundValues(); qLog(Error) << "bound values: " << query.boundValues();
emit Error("LibraryBackend: " + last_error.text()); emit Error("LibraryBackend: " + last_error.text());
return true; return true;

View File

@ -16,6 +16,7 @@
*/ */
#include "encoding.h" #include "encoding.h"
#include "core/logging.h"
#include <QTextCodec> #include <QTextCodec>
#include <QtDebug> #include <QtDebug>
@ -27,6 +28,7 @@
#include <vorbisfile.h> #include <vorbisfile.h>
#include <flacfile.h> #include <flacfile.h>
#include "core/logging.h"
#include "engines/enginebase.h" #include "engines/enginebase.h"
UniversalEncodingHandler::UniversalEncodingHandler() UniversalEncodingHandler::UniversalEncodingHandler()
@ -91,7 +93,7 @@ QTextCodec* UniversalEncodingHandler::Guess(const char* data) {
repeats = 0; repeats = 0;
} }
if (repeats > 3) { if (repeats > 3) {
qWarning() << "Heuristic guessed windows-1251"; qLog(Warning) << "Heuristic guessed windows-1251";
current_codec_ = QTextCodec::codecForName("windows-1251"); current_codec_ = QTextCodec::codecForName("windows-1251");
} }
} }
@ -154,7 +156,7 @@ QTextCodec* UniversalEncodingHandler::Guess(const TagLib::String& input) {
return NULL; return NULL;
} }
if (input.isLatin1()) { if (input.isLatin1()) {
qWarning() << "Extended ASCII... possibly should be CP866 or windows-1251 instead"; qLog(Warning) << "Extended ASCII... possibly should be CP866 or windows-1251 instead";
std::string broken = input.toCString(true); std::string broken = input.toCString(true);
std::string fixed = QString::fromUtf8(broken.c_str()).toStdString(); std::string fixed = QString::fromUtf8(broken.c_str()).toStdString();
QTextCodec* codec = Guess(fixed.c_str()); QTextCodec* codec = Guess(fixed.c_str());
@ -181,16 +183,16 @@ QTextCodec* UniversalEncodingHandler::Guess(const Engine::SimpleMetaBundle& bund
QString UniversalEncodingHandler::FixEncoding(const TagLib::String& input) { QString UniversalEncodingHandler::FixEncoding(const TagLib::String& input) {
if (input.isLatin1() && !input.isAscii()) { if (input.isLatin1() && !input.isAscii()) {
qWarning() << "Extended ASCII... possibly should be CP866 or windows-1251 instead"; qLog(Warning) << "Extended ASCII... possibly should be CP866 or windows-1251 instead";
std::string broken = input.toCString(true); std::string broken = input.toCString(true);
std::string fixed; std::string fixed;
if (broken.size() > input.size()) { if (broken.size() > input.size()) {
fixed = QString::fromUtf8(broken.c_str()).toStdString(); fixed = QString::fromUtf8(broken.c_str()).toStdString();
QTextCodec* codec = Guess(fixed.c_str()); QTextCodec* codec = Guess(fixed.c_str());
if (!codec) { if (!codec) {
qDebug() << "Could not guess encoding. Using extended ASCII."; qLog(Debug) << "Could not guess encoding. Using extended ASCII.";
} else { } else {
qDebug() << "Guessed:" << codec->name(); qLog(Debug) << "Guessed:" << codec->name();
QString foo = codec->toUnicode(fixed.c_str()); QString foo = codec->toUnicode(fixed.c_str());
return foo.trimmed(); return foo.trimmed();
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "config.h" #include "config.h"
#include "core/logging.h"
#ifdef HAVE_GIO #ifdef HAVE_GIO
# include <gio/gio.h> # include <gio/gio.h>
@ -42,7 +43,7 @@ bool FilesystemMusicStorage::CopyToStorage(const CopyJob& job) {
const QString dest_directory = dest_filename.section('/', 0, -2); const QString dest_directory = dest_filename.section('/', 0, -2);
QDir dir; QDir dir;
if (!dir.mkpath(dest_directory)) { if (!dir.mkpath(dest_directory)) {
qWarning() << "Failed to create directory" << dest_directory; qLog(Warning) << "Failed to create directory" << dest_directory;
return false; return false;
} }

View File

@ -17,6 +17,7 @@
#include "gnomeglobalshortcutbackend.h" #include "gnomeglobalshortcutbackend.h"
#include "globalshortcuts.h" #include "globalshortcuts.h"
#include "core/logging.h"
#ifdef QT_DBUS_LIB #ifdef QT_DBUS_LIB
# include "dbus/gnomesettingsdaemon.h" # include "dbus/gnomesettingsdaemon.h"
@ -41,10 +42,10 @@ GnomeGlobalShortcutBackend::GnomeGlobalShortcutBackend(GlobalShortcuts* parent)
bool GnomeGlobalShortcutBackend::DoRegister() { bool GnomeGlobalShortcutBackend::DoRegister() {
#ifdef QT_DBUS_LIB #ifdef QT_DBUS_LIB
qDebug() << __PRETTY_FUNCTION__ << "- starting"; qLog(Debug) << "registering";
// Check if the GSD service is available // Check if the GSD service is available
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService)) { if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService)) {
qDebug() << __PRETTY_FUNCTION__ << "- gnome settings daemon not registered"; qLog(Warning) << "gnome settings daemon not registered";
return false; return false;
} }
@ -56,17 +57,17 @@ bool GnomeGlobalShortcutBackend::DoRegister() {
connect(interface_, SIGNAL(MediaPlayerKeyPressed(QString,QString)), connect(interface_, SIGNAL(MediaPlayerKeyPressed(QString,QString)),
this, SLOT(GnomeMediaKeyPressed(QString,QString))); this, SLOT(GnomeMediaKeyPressed(QString,QString)));
qDebug() << __PRETTY_FUNCTION__ << "- complete"; qLog(Debug) << "registered";
return true; return true;
#else // QT_DBUS_LIB #else // QT_DBUS_LIB
qDebug() << __PRETTY_FUNCTION__ << "- dbus not available"; qLog(Warning) << "dbus not available";
return false; return false;
#endif #endif
} }
void GnomeGlobalShortcutBackend::DoUnregister() { void GnomeGlobalShortcutBackend::DoUnregister() {
qDebug() << __PRETTY_FUNCTION__; qLog(Debug) << "unregister";
#ifdef QT_DBUS_LIB #ifdef QT_DBUS_LIB
// Check if the GSD service is available // Check if the GSD service is available
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService)) if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService))

176
src/core/logging.cpp Normal file
View File

@ -0,0 +1,176 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QCoreApplication>
#include <QDateTime>
#include <QStringList>
#include <glib.h>
#include "logging.h"
namespace logging {
static Level sDefaultLevel = Level_Debug;
static QMap<QString, Level>* sClassLevels = NULL;
static QIODevice* sNullDevice = NULL;
const char* kDefaultLogLevels = "GstEnginePipeline:2,*:3";
static const char* kMessageHandlerMagic = "__logging_message__";
static const int kMessageHandlerMagicLength = strlen(kMessageHandlerMagic);
static QtMsgHandler sOriginalMessageHandler = NULL;
static void GLog(const gchar* domain, GLogLevelFlags level,
const gchar* message, gpointer user_data) {
switch (level) {
case G_LOG_FLAG_RECURSION:
case G_LOG_FLAG_FATAL:
case G_LOG_LEVEL_ERROR:
case G_LOG_LEVEL_CRITICAL: qLog(Error) << message; break;
case G_LOG_LEVEL_WARNING: qLog(Warning) << message; break;
case G_LOG_LEVEL_MESSAGE:
case G_LOG_LEVEL_INFO: qLog(Info) << message; break;
case G_LOG_LEVEL_DEBUG:
default: qLog(Debug) << message; break;
}
}
static void MessageHandler(QtMsgType type, const char* message) {
if (strncmp(kMessageHandlerMagic, message, kMessageHandlerMagicLength) == 0) {
fprintf(stderr, "%s\n", message + kMessageHandlerMagicLength);
return;
}
Level level = Level_Debug;
switch (type) {
case QtFatalMsg:
case QtCriticalMsg: level = Level_Error; break;
case QtWarningMsg: level = Level_Warning; break;
case QtDebugMsg:
default: level = Level_Debug; break;
}
foreach (const QString& line, QString::fromLocal8Bit(message).split('\n')) {
CreateLogger(level, "unknown", -1) << line.toLocal8Bit().constData();
}
if (type == QtFatalMsg) {
abort();
}
}
void Init() {
delete sClassLevels;
delete sNullDevice;
sClassLevels = new QMap<QString, Level>();
sNullDevice = new NullDevice;
// Glib integration
g_log_set_default_handler(&GLog, NULL);
// Catch other messages from Qt
if (!sOriginalMessageHandler) {
sOriginalMessageHandler = qInstallMsgHandler(MessageHandler);
}
}
void SetLevels(const QString& levels) {
if (!sClassLevels)
return;
foreach (const QString& item, levels.split(',')) {
const QStringList class_level = item.split(':');
QString class_name;
bool ok = false;
int level = Level_Error;
if (class_level.count() == 1) {
level = class_level.last().toInt(&ok);
} else if (class_level.count() == 2) {
class_name = class_level.first();
level = class_level.last().toInt(&ok);
}
if (!ok || level < Level_Error || level > Level_Debug) {
continue;
}
if (class_name.isEmpty() || class_name == "*") {
sDefaultLevel = (Level) level;
} else {
sClassLevels->insert(class_name, (Level) level);
}
}
}
QDebug CreateLogger(Level level, const char* pretty_function, int line) {
// Map the level to a string
const char* level_name = NULL;
switch (level) {
case Level_Debug: level_name = " DEBUG "; break;
case Level_Info: level_name = " INFO "; break;
case Level_Warning: level_name = " WARN "; break;
case Level_Error: level_name = " ERROR "; break;
}
// Get the class name out of the function name.
QString class_name = pretty_function;
const int paren = class_name.indexOf('(');
if (paren != -1) {
const int colons = class_name.lastIndexOf("::", paren);
if (colons != -1) {
class_name = class_name.left(colons);
} else {
class_name = class_name.left(paren);
}
}
const int space = class_name.lastIndexOf(' ');
if (space != -1) {
class_name = class_name.mid(space+1);
}
// Check the settings to see if we're meant to show or hide this message.
Level threshold_level = sDefaultLevel;
if (sClassLevels && sClassLevels->contains(class_name)) {
threshold_level = sClassLevels->value(class_name);
}
if (level > threshold_level) {
return QDebug(sNullDevice);
}
QString function_line = class_name;
if (line != -1) {
function_line += ":" + QString::number(line);
}
QDebug ret(QtDebugMsg);
ret.nospace() << kMessageHandlerMagic
<< QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toAscii().constData()
<< level_name << function_line.leftJustified(32).toAscii().constData();
return ret.space();
}
} // namespace logging

48
src/core/logging.h Normal file
View File

@ -0,0 +1,48 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOGGING_H
#define LOGGING_H
#include <QDebug>
#define qLog(level) \
logging::CreateLogger(logging::Level_##level, __PRETTY_FUNCTION__, __LINE__)
namespace logging {
class NullDevice : public QIODevice {
protected:
qint64 readData(char*, qint64) { return -1; }
qint64 writeData(const char*, qint64 len) { return len; }
};
enum Level {
Level_Error = 0,
Level_Warning,
Level_Info,
Level_Debug,
};
void Init();
void SetLevels(const QString& levels);
QDebug CreateLogger(Level level, const char* pretty_function, int line);
extern const char* kDefaultLogLevels;
}
#endif // LOGGING_H

View File

@ -38,6 +38,7 @@
#include "mac_startup.h" #include "mac_startup.h"
#include "macglobalshortcutbackend.h" #include "macglobalshortcutbackend.h"
#include "utilities.h" #include "utilities.h"
#include "core/logging.h"
#ifdef HAVE_SPARKLE #ifdef HAVE_SPARKLE
#import <Sparkle/SUUpdater.h> #import <Sparkle/SUUpdater.h>
@ -285,7 +286,7 @@ bool MigrateLegacyConfigFiles() {
toPath:[NSString stringWithUTF8String: new_config_dir.toUtf8().constData()] toPath:[NSString stringWithUTF8String: new_config_dir.toUtf8().constData()]
error: &error]; error: &error];
if (!ret) { if (!ret) {
qWarning() << [[error localizedDescription] UTF8String]; qLog(Warning) << [[error localizedDescription] UTF8String];
} }
moved_dir = true; moved_dir = true;
} }
@ -295,7 +296,7 @@ bool MigrateLegacyConfigFiles() {
QSettings settings; QSettings settings;
bool ret = QFile::rename(old_config_path, settings.fileName()); bool ret = QFile::rename(old_config_path, settings.fileName());
if (ret) { if (ret) {
qWarning() << "Migrated old config file: " << old_config_path << "to: " << settings.fileName(); qLog(Warning) << "Migrated old config file: " << old_config_path << "to: " << settings.fileName();
} }
} }

View File

@ -17,6 +17,7 @@
#include "mpris1.h" #include "mpris1.h"
#include "mpris_common.h" #include "mpris_common.h"
#include "core/logging.h"
#include "covers/artloader.h" #include "covers/artloader.h"
#include <QCoreApplication> #include <QCoreApplication>
@ -51,7 +52,7 @@ Mpris1::Mpris1(PlayerInterface* player, ArtLoader* art_loader, QObject* parent,
} }
if (!QDBusConnection::sessionBus().registerService(dbus_service_name_)) { if (!QDBusConnection::sessionBus().registerService(dbus_service_name_)) {
qWarning() << "Failed to register" << dbus_service_name_ << "on the session bus"; qLog(Warning) << "Failed to register" << dbus_service_name_ << "on the session bus";
return; return;
} }

View File

@ -19,6 +19,7 @@
#include "mpris_common.h" #include "mpris_common.h"
#include "mpris1.h" #include "mpris1.h"
#include "mpris2.h" #include "mpris2.h"
#include "core/logging.h"
#include "core/mpris2_player.h" #include "core/mpris2_player.h"
#include "core/mpris2_root.h" #include "core/mpris2_root.h"
#include "core/mpris2_tracklist.h" #include "core/mpris2_tracklist.h"
@ -55,7 +56,7 @@ Mpris2::Mpris2(PlayerInterface* player, ArtLoader* art_loader,
new Mpris2Player(this); new Mpris2Player(this);
if (!QDBusConnection::sessionBus().registerService(kServiceName)) { if (!QDBusConnection::sessionBus().registerService(kServiceName)) {
qWarning() << "Failed to register" << QString(kServiceName) << "on the session bus"; qLog(Warning) << "Failed to register" << QString(kServiceName) << "on the session bus";
return; return;
} }

View File

@ -1,4 +1,5 @@
#include "networkproxyfactory.h" #include "networkproxyfactory.h"
#include "core/logging.h"
#include <QMutexLocker> #include <QMutexLocker>
#include <QSettings> #include <QSettings>
@ -26,7 +27,7 @@ NetworkProxyFactory::NetworkProxyFactory()
urls << QString::fromLocal8Bit(getenv("ALL_PROXY")); urls << QString::fromLocal8Bit(getenv("ALL_PROXY"));
urls << QString::fromLocal8Bit(getenv("all_proxy")); urls << QString::fromLocal8Bit(getenv("all_proxy"));
qDebug() << "Detected system proxy URLs:" << urls; qLog(Debug) << "Detected system proxy URLs:" << urls;
foreach (const QString& url_str, urls) { foreach (const QString& url_str, urls) {
if (url_str.isEmpty()) if (url_str.isEmpty())
@ -85,7 +86,7 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(
ret.setType(QNetworkProxy::HttpProxy); ret.setType(QNetworkProxy::HttpProxy);
else else
ret.setType(QNetworkProxy::Socks5Proxy); ret.setType(QNetworkProxy::Socks5Proxy);
qDebug() << "Using proxy URL:" << env_url_; qLog(Debug) << "Using proxy URL:" << env_url_;
} }
break; break;
#else #else

View File

@ -18,6 +18,7 @@
#include "musicstorage.h" #include "musicstorage.h"
#include "organise.h" #include "organise.h"
#include "taskmanager.h" #include "taskmanager.h"
#include "core/logging.h"
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
@ -87,7 +88,7 @@ void Organise::ProcessSomeFiles() {
if (tasks_pending_.isEmpty()) { if (tasks_pending_.isEmpty()) {
if (!tasks_transcoding_.isEmpty()) { if (!tasks_transcoding_.isEmpty()) {
// Just wait - FileTranscoded will start us off again in a little while // Just wait - FileTranscoded will start us off again in a little while
qDebug() << "Waiting for transcoding jobs"; qLog(Debug) << "Waiting for transcoding jobs";
transcode_progress_timer_.start(kTranscodeProgressInterval, this); transcode_progress_timer_.start(kTranscodeProgressInterval, this);
return; return;
} }
@ -120,7 +121,7 @@ void Organise::ProcessSomeFiles() {
break; break;
Task task = tasks_pending_.takeFirst(); Task task = tasks_pending_.takeFirst();
qDebug() << "Processing" << task.filename_; qLog(Info) << "Processing" << task.filename_;
// Is it a directory? // Is it a directory?
if (QFileInfo(task.filename_).isDir()) { if (QFileInfo(task.filename_).isDir()) {
@ -141,7 +142,7 @@ void Organise::ProcessSomeFiles() {
// Maybe this file is one that's been transcoded already? // Maybe this file is one that's been transcoded already?
if (!task.transcoded_filename_.isEmpty()) { if (!task.transcoded_filename_.isEmpty()) {
qDebug() << "This file has already been transcoded"; qLog(Debug) << "This file has already been transcoded";
// Set the new filetype on the song so the formatter gets it right // Set the new filetype on the song so the formatter gets it right
song.set_filetype(task.new_filetype_); song.set_filetype(task.new_filetype_);
@ -158,7 +159,7 @@ void Organise::ProcessSomeFiles() {
if (dest_type != Song::Type_Unknown) { if (dest_type != Song::Type_Unknown) {
// Get the preset // Get the preset
TranscoderPreset preset = Transcoder::PresetForFileType(dest_type); TranscoderPreset preset = Transcoder::PresetForFileType(dest_type);
qDebug() << "Transcoding with" << preset.name_; qLog(Debug) << "Transcoding with" << preset.name_;
// Get a temporary name for the transcoded file // Get a temporary name for the transcoded file
task.transcoded_filename_ = transcode_temp_name_.fileName() + "-" + task.transcoded_filename_ = transcode_temp_name_.fileName() + "-" +
@ -167,7 +168,7 @@ void Organise::ProcessSomeFiles() {
task.new_filetype_ = dest_type; task.new_filetype_ = dest_type;
tasks_transcoding_[task.filename_] = task; tasks_transcoding_[task.filename_] = task;
qDebug() << "Transcoding to" << task.transcoded_filename_; qLog(Debug) << "Transcoding to" << task.transcoded_filename_;
// Start the transcoding - this will happen in the background and // Start the transcoding - this will happen in the background and
// FileTranscoded() will get called when it's done. At that point the // FileTranscoded() will get called when it's done. At that point the
@ -271,7 +272,7 @@ void Organise::UpdateProgress() {
} }
void Organise::FileTranscoded(const QString& filename, bool success) { void Organise::FileTranscoded(const QString& filename, bool success) {
qDebug() << "File finished" << filename << success; qLog(Info) << "File finished" << filename << success;
transcode_progress_timer_.stop(); transcode_progress_timer_.stop();
Task task = tasks_transcoding_.take(filename); Task task = tasks_transcoding_.take(filename);

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include "player.h" #include "player.h"
#include "core/logging.h"
#include "engines/enginebase.h" #include "engines/enginebase.h"
#include "engines/gstengine.h" #include "engines/gstengine.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
@ -299,7 +300,7 @@ void Player::SeekTo(int seconds) {
engine_->Seek(nanosec); engine_->Seek(nanosec);
// If we seek the track we don't want to submit it to last.fm // If we seek the track we don't want to submit it to last.fm
qDebug() << "Track seeked to" << nanosec << "ns - not scrobbling"; qLog(Info) << "Track seeked to" << nanosec << "ns - not scrobbling";
if (playlists_->active()->get_lastfm_status() == Playlist::LastFM_New) { if (playlists_->active()->get_lastfm_status() == Playlist::LastFM_New) {
playlists_->active()->set_lastfm_status(Playlist::LastFM_Seeked); playlists_->active()->set_lastfm_status(Playlist::LastFM_Seeked);
} }

View File

@ -18,6 +18,7 @@
#include "globalshortcuts.h" #include "globalshortcuts.h"
#include "qxtglobalshortcutbackend.h" #include "qxtglobalshortcutbackend.h"
#include "qxtglobalshortcut.h" #include "qxtglobalshortcut.h"
#include "core/logging.h"
#include <QAction> #include <QAction>
#include <QtDebug> #include <QtDebug>
@ -28,7 +29,7 @@ QxtGlobalShortcutBackend::QxtGlobalShortcutBackend(GlobalShortcuts *parent)
} }
bool QxtGlobalShortcutBackend::DoRegister() { bool QxtGlobalShortcutBackend::DoRegister() {
qDebug() << __PRETTY_FUNCTION__; qLog(Debug) << "registering";
foreach (const GlobalShortcuts::Shortcut& shortcut, manager_->shortcuts().values()) { foreach (const GlobalShortcuts::Shortcut& shortcut, manager_->shortcuts().values()) {
AddShortcut(shortcut.action); AddShortcut(shortcut.action);
} }
@ -46,7 +47,7 @@ void QxtGlobalShortcutBackend::AddShortcut(QAction* action) {
} }
void QxtGlobalShortcutBackend::DoUnregister() { void QxtGlobalShortcutBackend::DoUnregister() {
qDebug() << __PRETTY_FUNCTION__; qLog(Debug) << "unregistering";
qDeleteAll(shortcuts_); qDeleteAll(shortcuts_);
shortcuts_.clear(); shortcuts_.clear();
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "scopedtransaction.h" #include "scopedtransaction.h"
#include "core/logging.h"
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QtDebug> #include <QtDebug>
@ -29,14 +30,14 @@ ScopedTransaction::ScopedTransaction(QSqlDatabase* db)
ScopedTransaction::~ScopedTransaction() { ScopedTransaction::~ScopedTransaction() {
if (pending_) { if (pending_) {
qDebug() << __PRETTY_FUNCTION__ << "Rolling back transaction"; qLog(Warning) << "Rolling back transaction";
db_->rollback(); db_->rollback();
} }
} }
void ScopedTransaction::Commit() { void ScopedTransaction::Commit() {
if (!pending_) { if (!pending_) {
qWarning() << "Tried to commit a ScopedTransaction twice"; qLog(Warning) << "Tried to commit a ScopedTransaction twice";
return; return;
} }

View File

@ -17,6 +17,7 @@
#include "fmpsparser.h" #include "fmpsparser.h"
#include "song.h" #include "song.h"
#include "core/logging.h"
#include <algorithm> #include <algorithm>
@ -248,7 +249,7 @@ QString Song::Decode(const QString& tag, const QTextCodec* codec) {
bool Song::HasProperMediaFile() const { bool Song::HasProperMediaFile() const {
#ifndef QT_NO_DEBUG_OUTPUT #ifndef QT_NO_DEBUG_OUTPUT
if (qApp->thread() == QThread::currentThread()) if (qApp->thread() == QThread::currentThread())
qWarning() << Q_FUNC_INFO << "on GUI thread!"; qLog(Warning) << "HasProperMediaFile() on GUI thread!";
#endif #endif
QMutexLocker l(&taglib_mutex_); QMutexLocker l(&taglib_mutex_);
@ -260,7 +261,7 @@ bool Song::HasProperMediaFile() const {
void Song::InitFromFile(const QString& filename, int directory_id) { void Song::InitFromFile(const QString& filename, int directory_id) {
#ifndef QT_NO_DEBUG_OUTPUT #ifndef QT_NO_DEBUG_OUTPUT
if (qApp->thread() == QThread::currentThread()) if (qApp->thread() == QThread::currentThread())
qWarning() << Q_FUNC_INFO << "on GUI thread!"; qLog(Warning) << "InitFromFile() on GUI thread!";
#endif #endif
d->init_from_file_ = true; d->init_from_file_ = true;
@ -764,7 +765,7 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
break; break;
} }
default: default:
qWarning() << "Type" << value.type() << "not handled"; qLog(Warning) << "Type" << value.type() << "not handled";
Q_ASSERT(0); Q_ASSERT(0);
break; break;
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "songloader.h" #include "songloader.h"
#include "core/logging.h"
#include "core/song.h" #include "core/song.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "library/sqlrow.h" #include "library/sqlrow.h"
@ -83,7 +84,7 @@ SongLoader::Result SongLoader::Load(const QUrl& url) {
} }
SongLoader::Result SongLoader::LoadLocalPartial(const QString& filename) { SongLoader::Result SongLoader::LoadLocalPartial(const QString& filename) {
qDebug() << "Fast Loading local file" << filename; qLog(Debug) << "Fast Loading local file" << filename;
// First check to see if it's a directory - if so we can load all the songs // First check to see if it's a directory - if so we can load all the songs
// inside right away. // inside right away.
if (QFileInfo(filename).isDir()) { if (QFileInfo(filename).isDir()) {
@ -99,7 +100,7 @@ SongLoader::Result SongLoader::LoadLocalPartial(const QString& filename) {
SongLoader::Result SongLoader::LoadLocal(const QString& filename, bool block, SongLoader::Result SongLoader::LoadLocal(const QString& filename, bool block,
bool ignore_playlists) { bool ignore_playlists) {
qDebug() << "Loading local file" << filename; qLog(Debug) << "Loading local file" << filename;
// First check to see if it's a directory - if so we can load all the songs // First check to see if it's a directory - if so we can load all the songs
// inside right away. // inside right away.
@ -129,11 +130,11 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename, bool block,
if (parser) { if (parser) {
if (ignore_playlists) { if (ignore_playlists) {
qDebug() << "Skipping" << parser->name() << "playlist while loading directory"; qLog(Debug) << "Skipping" << parser->name() << "playlist while loading directory";
return Success; return Success;
} }
qDebug() << "Parsing using" << parser->name(); qLog(Debug) << "Parsing using" << parser->name();
// It's a playlist! // It's a playlist!
if (!block) { if (!block) {
@ -275,14 +276,14 @@ void SongLoader::StopTypefind() {
timeout_timer_->stop(); timeout_timer_->stop();
if (success_ && parser_) { if (success_ && parser_) {
qDebug() << "Parsing" << url_ << "with" << parser_->name(); qLog(Debug) << "Parsing" << url_ << "with" << parser_->name();
// Parse the playlist // Parse the playlist
QBuffer buf(&buffer_); QBuffer buf(&buffer_);
buf.open(QIODevice::ReadOnly); buf.open(QIODevice::ReadOnly);
songs_ = parser_->Load(&buf); songs_ = parser_->Load(&buf);
} else if (success_) { } else if (success_) {
qDebug() << "Loading" << url_ << "as raw stream"; qLog(Debug) << "Loading" << url_ << "as raw stream";
// It wasn't a playlist - just put the URL in as a stream // It wasn't a playlist - just put the URL in as a stream
AddAsRawStream(); AddAsRawStream();
@ -292,7 +293,7 @@ void SongLoader::StopTypefind() {
} }
SongLoader::Result SongLoader::LoadRemote() { SongLoader::Result SongLoader::LoadRemote() {
qDebug() << "Loading remote file" << url_; qLog(Debug) << "Loading remote file" << url_;
// It's not a local file so we have to fetch it to see what it is. We use // It's not a local file so we have to fetch it to see what it is. We use
// gstreamer to do this since it handles funky URLs for us (http://, ssh://, // gstreamer to do this since it handles funky URLs for us (http://, ssh://,
@ -312,7 +313,7 @@ SongLoader::Result SongLoader::LoadRemote() {
GstElement* source = gst_element_make_from_uri( GstElement* source = gst_element_make_from_uri(
GST_URI_SRC, url_.toEncoded().constData(), NULL); GST_URI_SRC, url_.toEncoded().constData(), NULL);
if (!source) { if (!source) {
qWarning() << "Couldn't create gstreamer source element for" << url_.toString(); qLog(Warning) << "Couldn't create gstreamer source element for" << url_.toString();
return Error; return Error;
} }
@ -348,7 +349,7 @@ void SongLoader::TypeFound(GstElement*, uint, GstCaps* caps, void* self) {
// Check the mimetype // Check the mimetype
instance->mime_type_ = gst_structure_get_name(gst_caps_get_structure(caps, 0)); instance->mime_type_ = gst_structure_get_name(gst_caps_get_structure(caps, 0));
qDebug() << "Mime type is" << instance->mime_type_; qLog(Debug) << "Mime type is" << instance->mime_type_;
if (instance->mime_type_ == "text/plain" || if (instance->mime_type_ == "text/plain" ||
instance->mime_type_ == "text/uri-list" || instance->mime_type_ == "text/uri-list" ||
instance->mime_type_ == "application/xml") { instance->mime_type_ == "application/xml") {
@ -370,7 +371,7 @@ void SongLoader::DataReady(GstPad *, GstBuffer *buf, void *self) {
// Append the data to the buffer // Append the data to the buffer
instance->buffer_.append(reinterpret_cast<const char*>(GST_BUFFER_DATA(buf)), instance->buffer_.append(reinterpret_cast<const char*>(GST_BUFFER_DATA(buf)),
GST_BUFFER_SIZE(buf)); GST_BUFFER_SIZE(buf));
qDebug() << "Received total" << instance->buffer_.size() << "bytes"; qLog(Debug) << "Received total" << instance->buffer_.size() << "bytes";
if (instance->state_ == WaitingForMagic && if (instance->state_ == WaitingForMagic &&
instance->buffer_.size() >= PlaylistParser::kMagicSize) { instance->buffer_.size() >= PlaylistParser::kMagicSize) {
@ -419,8 +420,8 @@ void SongLoader::ErrorMessageReceived(GstMessage* msg) {
gchar* debugs; gchar* debugs;
gst_message_parse_error(msg, &error, &debugs); gst_message_parse_error(msg, &error, &debugs);
qDebug() << error->message; qLog(Error) << error->message;
qDebug() << debugs; qLog(Error) << debugs;
QString message_str = error->message; QString message_str = error->message;
@ -466,7 +467,7 @@ void SongLoader::MagicReady() {
parser_ = playlist_parser_->ParserForMagic(buffer_, mime_type_); parser_ = playlist_parser_->ParserForMagic(buffer_, mime_type_);
if (!parser_) { if (!parser_) {
qWarning() << url_.toString() << "is text, but not a recognised playlist"; qLog(Warning) << url_.toString() << "is text, but not a recognised playlist";
// It doesn't look like a playlist, so just finish // It doesn't look like a playlist, so just finish
StopTypefindAsync(false); StopTypefindAsync(false);
return; return;
@ -474,7 +475,7 @@ void SongLoader::MagicReady() {
// It is a playlist - we'll get more data and parse the whole thing in // It is a playlist - we'll get more data and parse the whole thing in
// EndOfStreamReached // EndOfStreamReached
qDebug() << "Magic says" << parser_->name(); qLog(Debug) << "Magic says" << parser_->name();
if (parser_->name() == "ASX/INI" && url_.scheme() == "http") { if (parser_->name() == "ASX/INI" && url_.scheme() == "http") {
// This is actually a weird MS-WMSP stream. Changing the protocol to MMS from // This is actually a weird MS-WMSP stream. Changing the protocol to MMS from
// HTTP makes it playable. // HTTP makes it playable.

View File

@ -16,6 +16,7 @@
*/ */
#include "stylesheetloader.h" #include "stylesheetloader.h"
#include "core/logging.h"
#include <QtDebug> #include <QtDebug>
#include <QFile> #include <QFile>
@ -38,7 +39,7 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget) {
// Load the file // Load the file
QFile file(filename); QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
qWarning() << __PRETTY_FUNCTION__ << "error opening" << filename; qLog(Warning) << "error opening" << filename;
return; return;
} }
QString contents(file.readAll()); QString contents(file.readAll());

View File

@ -17,6 +17,7 @@
#include "timeconstants.h" #include "timeconstants.h"
#include "utilities.h" #include "utilities.h"
#include "core/logging.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDateTime> #include <QDateTime>
@ -189,14 +190,14 @@ bool CopyRecursive(const QString& source, const QString& destination) {
QDir dir(source); QDir dir(source);
foreach (const QString& child, dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) { foreach (const QString& child, dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) {
if (!CopyRecursive(source + "/" + child, dest_path)) { if (!CopyRecursive(source + "/" + child, dest_path)) {
qWarning() << "Failed to copy dir" << source + "/" + child << "to" << dest_path; qLog(Warning) << "Failed to copy dir" << source + "/" + child << "to" << dest_path;
return false; return false;
} }
} }
foreach (const QString& child, dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) { foreach (const QString& child, dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) {
if (!QFile::copy(source + "/" + child, dest_path + "/" + child)) { if (!QFile::copy(source + "/" + child, dest_path + "/" + child)) {
qWarning() << "Failed to copy file" << source + "/" + child << "to" << dest_path; qLog(Warning) << "Failed to copy file" << source + "/" + child << "to" << dest_path;
return false; return false;
} }
} }

View File

@ -19,6 +19,7 @@
#include "devicelister.h" #include "devicelister.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "core/database.h" #include "core/database.h"
#include "core/logging.h"
#include "library/library.h" #include "library/library.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "library/librarymodel.h" #include "library/librarymodel.h"
@ -39,7 +40,7 @@ ConnectedDevice::ConnectedDevice(const QUrl& url, DeviceLister* lister,
model_(NULL), model_(NULL),
song_count_(0) song_count_(0)
{ {
qDebug() << __PRETTY_FUNCTION__; qLog(Info) << "connected" << url << unique_id << first_time;
// Create the backend in the database thread. // Create the backend in the database thread.
backend_ = new LibraryBackend(); backend_ = new LibraryBackend();
@ -77,7 +78,7 @@ void ConnectedDevice::InitBackendDirectory(
Directory dir = backend_->GetAllDirectories()[0]; Directory dir = backend_->GetAllDirectories()[0];
if (dir.path != mount_point) { if (dir.path != mount_point) {
// The directory is different, commence the munging. // The directory is different, commence the munging.
qDebug() << "Changing path from" << dir.path << "to" << mount_point; qLog(Info) << "Changing path from" << dir.path << "to" << mount_point;
backend_->ChangeDirPath(dir.id, mount_point); backend_->ChangeDirPath(dir.id, mount_point);
} }
} }

View File

@ -18,6 +18,7 @@
#include "config.h" #include "config.h"
#include "devicekitlister.h" #include "devicekitlister.h"
#include "filesystemdevice.h" #include "filesystemdevice.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include "dbus/udisks.h" #include "dbus/udisks.h"
#include "dbus/udisksdevice.h" #include "dbus/udisksdevice.h"
@ -52,7 +53,7 @@ void DeviceKitLister::Init() {
reply.waitForFinished(); reply.waitForFinished();
if (!reply.isValid()) { if (!reply.isValid()) {
qWarning() << "Error enumerating DeviceKit-disks devices:" << reply.error().name() << reply.error().message(); qLog(Warning) << "Error enumerating DeviceKit-disks devices:" << reply.error().name() << reply.error().message();
interface_.reset(); interface_.reset();
return; return;
} }
@ -149,7 +150,7 @@ DeviceKitLister::DeviceData DeviceKitLister::ReadDeviceData(
OrgFreedesktopUDisksInterface::staticInterfaceName(), OrgFreedesktopUDisksInterface::staticInterfaceName(),
path.path(), QDBusConnection::systemBus()); path.path(), QDBusConnection::systemBus());
if (!device.isValid()) { if (!device.isValid()) {
qWarning() << "Error connecting to the device interface on" << path.path(); qLog(Warning) << "Error connecting to the device interface on" << path.path();
return ret; return ret;
} }
@ -251,7 +252,7 @@ void DeviceKitLister::UnmountDevice(const QString& id) {
OrgFreedesktopUDisksInterface::staticInterfaceName(), OrgFreedesktopUDisksInterface::staticInterfaceName(),
path, QDBusConnection::systemBus()); path, QDBusConnection::systemBus());
if (!device.isValid()) { if (!device.isValid()) {
qWarning() << "Error connecting to the device interface on" << path; qLog(Warning) << "Error connecting to the device interface on" << path;
return; return;
} }
@ -261,7 +262,7 @@ void DeviceKitLister::UnmountDevice(const QString& id) {
OrgFreedesktopUDisksInterface::staticInterfaceName(), OrgFreedesktopUDisksInterface::staticInterfaceName(),
drive_path, QDBusConnection::systemBus()); drive_path, QDBusConnection::systemBus());
if (!drive.isValid()) { if (!drive.isValid()) {
qWarning() << "Error connecting to the drive interface on" << drive_path; qLog(Warning) << "Error connecting to the drive interface on" << drive_path;
return; return;
} }

View File

@ -183,9 +183,6 @@ QStringList DeviceLister::GuessIconForPath(const QString& path) {
Itdb_Device* device = itdb_device_new(); Itdb_Device* device = itdb_device_new();
itdb_device_set_mountpoint(device, path.toLocal8Bit().constData()); itdb_device_set_mountpoint(device, path.toLocal8Bit().constData());
const Itdb_IpodInfo* info = itdb_device_get_ipod_info(device); const Itdb_IpodInfo* info = itdb_device_get_ipod_info(device);
qDebug() << info->model_number
<< info->ipod_model
<< GetIpodColour(info->ipod_model);
QString colour = GetIpodColour(info->ipod_model); QString colour = GetIpodColour(info->ipod_model);
QString model = GetIpodModel(info->ipod_model); QString model = GetIpodModel(info->ipod_model);

View File

@ -21,6 +21,7 @@
#include "devicemanager.h" #include "devicemanager.h"
#include "devicestatefiltermodel.h" #include "devicestatefiltermodel.h"
#include "filesystemdevice.h" #include "filesystemdevice.h"
#include "core/logging.h"
#include "core/musicstorage.h" #include "core/musicstorage.h"
#include "core/taskmanager.h" #include "core/taskmanager.h"
#include "core/utilities.h" #include "core/utilities.h"
@ -389,7 +390,7 @@ int DeviceManager::FindDeviceByUrl(const QList<QUrl>& urls) const {
void DeviceManager::PhysicalDeviceAdded(const QString &id) { void DeviceManager::PhysicalDeviceAdded(const QString &id) {
DeviceLister* lister = qobject_cast<DeviceLister*>(sender()); DeviceLister* lister = qobject_cast<DeviceLister*>(sender());
qDebug() << "Device added:" << id; qLog(Info) << "Device added:" << id;
// Do we have this device already? // Do we have this device already?
int i = FindDeviceById(id); int i = FindDeviceById(id);
@ -438,7 +439,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
void DeviceManager::PhysicalDeviceRemoved(const QString &id) { void DeviceManager::PhysicalDeviceRemoved(const QString &id) {
DeviceLister* lister = qobject_cast<DeviceLister*>(sender()); DeviceLister* lister = qobject_cast<DeviceLister*>(sender());
qDebug() << "Device removed:" << id; qLog(Info) << "Device removed:" << id;
int i = FindDeviceById(id); int i = FindDeviceById(id);
if (i == -1) { if (i == -1) {
@ -533,7 +534,7 @@ boost::shared_ptr<ConnectedDevice> DeviceManager::Connect(int row) {
// Take the first URL that we have a handler for // Take the first URL that we have a handler for
QUrl device_url; QUrl device_url;
foreach (const QUrl& url, urls) { foreach (const QUrl& url, urls) {
qDebug() << "Connecting" << url; qLog(Info) << "Connecting" << url;
// Find a device class for this URL's scheme // Find a device class for this URL's scheme
if (device_classes_.contains(url.scheme())) { if (device_classes_.contains(url.scheme())) {
@ -578,7 +579,7 @@ boost::shared_ptr<ConnectedDevice> DeviceManager::Connect(int row) {
ret.reset(static_cast<ConnectedDevice*>(instance)); ret.reset(static_cast<ConnectedDevice*>(instance));
if (!ret) { if (!ret) {
qWarning() << "Could not create device for" << device_url.toString(); qLog(Warning) << "Could not create device for" << device_url.toString();
} else { } else {
ret->Init(); ret->Init();

View File

@ -67,5 +67,4 @@ void FilesystemDevice::Init() {
} }
FilesystemDevice::~FilesystemDevice() { FilesystemDevice::~FilesystemDevice() {
qDebug() << __PRETTY_FUNCTION__;
} }

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include "giolister.h" #include "giolister.h"
#include "core/logging.h"
#include <QFile> #include <QFile>
#include <QStringList> #include <QStringList>
@ -56,7 +57,7 @@ void OperationFinished(F f, GObject *object, GAsyncResult *result) {
f(obj, result, &error); f(obj, result, &error);
if (error) { if (error) {
qDebug() << "Mount/unmount error:" << error->message; qLog(Error) << "Mount/unmount error:" << error->message;
g_error_free(error); g_error_free(error);
} }
} }
@ -368,7 +369,7 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
G_FILE_ATTRIBUTE_FILESYSTEM_SIZE "," G_FILE_ATTRIBUTE_FILESYSTEM_FREE "," G_FILE_ATTRIBUTE_FILESYSTEM_SIZE "," G_FILE_ATTRIBUTE_FILESYSTEM_FREE ","
G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, NULL, &error); G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, NULL, &error);
if (error) { if (error) {
qWarning() << error->message; qLog(Warning) << error->message;
g_error_free(error); g_error_free(error);
} else { } else {
filesystem_size = g_file_info_get_attribute_uint64( filesystem_size = g_file_info_get_attribute_uint64(
@ -387,7 +388,7 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
info = g_file_query_info(root, G_FILE_ATTRIBUTE_ID_FILESYSTEM, info = g_file_query_info(root, G_FILE_ATTRIBUTE_ID_FILESYSTEM,
G_FILE_QUERY_INFO_NONE, NULL, &error); G_FILE_QUERY_INFO_NONE, NULL, &error);
if (error) { if (error) {
qWarning() << error->message; qLog(Warning) << error->message;
g_error_free(error); g_error_free(error);
} else { } else {
mount_uuid = QString::fromUtf8(g_file_info_get_attribute_string( mount_uuid = QString::fromUtf8(g_file_info_get_attribute_string(
@ -498,7 +499,7 @@ void GioLister::UpdateDeviceFreeSpace(const QString& id) {
GFileInfo* info = g_file_query_filesystem_info( GFileInfo* info = g_file_query_filesystem_info(
root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, NULL, &error); root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, NULL, &error);
if (error) { if (error) {
qWarning() << error->message; qLog(Warning) << error->message;
g_error_free(error); g_error_free(error);
} else { } else {
device_info.filesystem_free = g_file_info_get_attribute_uint64( device_info.filesystem_free = g_file_info_get_attribute_uint64(

View File

@ -18,6 +18,7 @@
#include "devicemanager.h" #include "devicemanager.h"
#include "gpoddevice.h" #include "gpoddevice.h"
#include "gpodloader.h" #include "gpodloader.h"
#include "core/logging.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "library/librarymodel.h" #include "library/librarymodel.h"
@ -114,7 +115,7 @@ bool GPodDevice::CopyToStorage(const CopyJob& job) {
itdb_cp_track_to_ipod(track, QDir::toNativeSeparators(job.source_) itdb_cp_track_to_ipod(track, QDir::toNativeSeparators(job.source_)
.toLocal8Bit().constData(), &error); .toLocal8Bit().constData(), &error);
if (error) { if (error) {
qDebug() << "GPodDevice error:" << error->message; qLog(Error) << "copying failed:" << error->message;
emit Error(QString::fromUtf8(error->message)); emit Error(QString::fromUtf8(error->message));
g_error_free(error); g_error_free(error);
@ -139,7 +140,7 @@ void GPodDevice::WriteDatabase(bool success) {
GError* error = NULL; GError* error = NULL;
itdb_write(db_, &error); itdb_write(db_, &error);
if (error) { if (error) {
qDebug() << "GPodDevice error:" << error->message; qLog(Error) << "writing database failed:" << error->message;
emit Error(QString::fromUtf8(error->message)); emit Error(QString::fromUtf8(error->message));
g_error_free(error); g_error_free(error);
} else { } else {
@ -186,7 +187,7 @@ bool GPodDevice::RemoveTrackFromITunesDb(const QString& path, const QString& rel
} }
if (track == NULL) { if (track == NULL) {
qWarning() << "Couldn't find song" << path << "in iTunesDB"; qLog(Warning) << "Couldn't find song" << path << "in iTunesDB";
return false; return false;
} }

View File

@ -17,6 +17,7 @@
#include "connecteddevice.h" #include "connecteddevice.h"
#include "gpodloader.h" #include "gpodloader.h"
#include "core/logging.h"
#include "core/song.h" #include "core/song.h"
#include "core/taskmanager.h" #include "core/taskmanager.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
@ -53,7 +54,7 @@ void GPodLoader::LoadDatabase() {
// Check for errors // Check for errors
if (!db) { if (!db) {
if (error) { if (error) {
qDebug() << "GPodLoader error:" << error->message; qLog(Error) << "loading database failed:" << error->message;
emit Error(QString::fromUtf8(error->message)); emit Error(QString::fromUtf8(error->message));
g_error_free(error); g_error_free(error);
} else { } else {

View File

@ -16,6 +16,7 @@
*/ */
#include "imobiledeviceconnection.h" #include "imobiledeviceconnection.h"
#include "core/logging.h"
#include <plist/plist.h> #include <plist/plist.h>
@ -26,7 +27,7 @@ iMobileDeviceConnection::iMobileDeviceConnection(const QString& uuid)
: device_(NULL), afc_(NULL), afc_port_(0) { : device_(NULL), afc_(NULL), afc_port_(0) {
idevice_error_t err = idevice_new(&device_, uuid.toUtf8().constData()); idevice_error_t err = idevice_new(&device_, uuid.toUtf8().constData());
if (err != IDEVICE_E_SUCCESS) { if (err != IDEVICE_E_SUCCESS) {
qWarning() << "idevice error:" << err; qLog(Warning) << "idevice error:" << err;
return; return;
} }
@ -37,20 +38,20 @@ iMobileDeviceConnection::iMobileDeviceConnection(const QString& uuid)
lockdownd_error_t lockdown_err = lockdownd_error_t lockdown_err =
lockdownd_client_new_with_handshake(device_, &lockdown, label); lockdownd_client_new_with_handshake(device_, &lockdown, label);
if (lockdown_err != LOCKDOWN_E_SUCCESS) { if (lockdown_err != LOCKDOWN_E_SUCCESS) {
qWarning() << "lockdown error:" << lockdown_err; qLog(Warning) << "lockdown error:" << lockdown_err;
return; return;
} }
lockdown_err = lockdownd_start_service(lockdown, "com.apple.afc", &afc_port_); lockdown_err = lockdownd_start_service(lockdown, "com.apple.afc", &afc_port_);
if (lockdown_err != LOCKDOWN_E_SUCCESS) { if (lockdown_err != LOCKDOWN_E_SUCCESS) {
qWarning() << "lockdown error:" << lockdown_err; qLog(Warning) << "lockdown error:" << lockdown_err;
lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
return; return;
} }
afc_error_t afc_err = afc_client_new(device_, afc_port_, &afc_); afc_error_t afc_err = afc_client_new(device_, afc_port_, &afc_);
if (afc_err != 0) { if (afc_err != 0) {
qWarning() << "afc error:" << afc_err; qLog(Warning) << "afc error:" << afc_err;
lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
return; return;
} }
@ -82,7 +83,7 @@ QVariant iMobileDeviceConnection::GetProperty(const QString& property, const QSt
lockdownd_error_t lockdown_err = lockdownd_error_t lockdown_err =
lockdownd_client_new_with_handshake(device_, &lockdown, label); lockdownd_client_new_with_handshake(device_, &lockdown, label);
if (lockdown_err != LOCKDOWN_E_SUCCESS) { if (lockdown_err != LOCKDOWN_E_SUCCESS) {
qWarning() << "lockdown error:" << lockdown_err; qLog(Warning) << "lockdown error:" << lockdown_err;
return QVariant(); return QVariant();
} }
@ -94,7 +95,7 @@ QVariant iMobileDeviceConnection::GetProperty(const QString& property, const QSt
lockdownd_client_free(lockdown); lockdownd_client_free(lockdown);
if (!node) { if (!node) {
qWarning() << "get_value failed" << property << domain; qLog(Warning) << "get_value failed" << property << domain;
return QVariant(); return QVariant();
} }
@ -113,7 +114,7 @@ QVariant iMobileDeviceConnection::GetProperty(const QString& property, const QSt
} }
default: default:
qWarning() << "Unhandled PList type"; qLog(Warning) << "Unhandled PList type";
return QVariant(); return QVariant();
} }
} }
@ -199,7 +200,7 @@ QString iMobileDeviceConnection::GetUnusedFilename(
} }
if (total_musicdirs <= 0) { if (total_musicdirs <= 0) {
qWarning() << "No 'F..'' directories found on iPod"; qLog(Warning) << "No 'F..'' directories found on iPod";
return QString(); return QString();
} }
@ -209,7 +210,7 @@ QString iMobileDeviceConnection::GetUnusedFilename(
dir.sprintf("/iTunes_Control/Music/F%02d", dir_num); dir.sprintf("/iTunes_Control/Music/F%02d", dir_num);
if (!Exists(dir)) { if (!Exists(dir)) {
qWarning() << "Music directory doesn't exist:" << dir; qLog(Warning) << "Music directory doesn't exist:" << dir;
return QString(); return QString();
} }

View File

@ -16,8 +16,8 @@
*/ */
#include "macdevicelister.h" #include "macdevicelister.h"
#include "mtpconnection.h" #include "mtpconnection.h"
#include "core/logging.h"
#include <CoreFoundation/CFRunLoop.h> #include <CoreFoundation/CFRunLoop.h>
#include <DiskArbitration/DiskArbitration.h> #include <DiskArbitration/DiskArbitration.h>
@ -93,7 +93,7 @@ void MacDeviceLister::Init() {
LIBMTP_device_entry_t* devices = NULL; LIBMTP_device_entry_t* devices = NULL;
int num = 0; int num = 0;
if (LIBMTP_Get_Supported_Devices_List(&devices, &num) != 0) { if (LIBMTP_Get_Supported_Devices_List(&devices, &num) != 0) {
qWarning() << "Failed to get MTP device list"; qLog(Warning) << "Failed to get MTP device list";
} else { } else {
for (int i = 0; i < num; ++i) { for (int i = 0; i < num; ++i) {
LIBMTP_device_entry_t device = devices[i]; LIBMTP_device_entry_t device = devices[i];
@ -143,7 +143,7 @@ void MacDeviceLister::Init() {
if (err == KERN_SUCCESS) { if (err == KERN_SUCCESS) {
USBDeviceAddedCallback(this, it); USBDeviceAddedCallback(this, it);
} else { } else {
qWarning() << "Could not add notification on USB device connection"; qLog(Warning) << "Could not add notification on USB device connection";
} }
err = IOServiceAddMatchingNotification( err = IOServiceAddMatchingNotification(
@ -156,7 +156,7 @@ void MacDeviceLister::Init() {
if (err == KERN_SUCCESS) { if (err == KERN_SUCCESS) {
USBDeviceRemovedCallback(this, it); USBDeviceRemovedCallback(this, it);
} else { } else {
qWarning() << "Could not add notification USB device removal"; qLog(Warning) << "Could not add notification USB device removal";
} }
CFRunLoopSourceRef io_source = IONotificationPortGetRunLoopSource(notification_port); CFRunLoopSourceRef io_source = IONotificationPortGetRunLoopSource(notification_port);
@ -303,7 +303,7 @@ quint64 MacDeviceLister::GetFreeSpace(const QUrl& url) {
QMutexLocker l(&libmtp_mutex_); QMutexLocker l(&libmtp_mutex_);
MtpConnection connection(url); MtpConnection connection(url);
if (!connection.is_valid()) { if (!connection.is_valid()) {
qWarning() << "Error connecting to MTP device, couldn't get device free space"; qLog(Warning) << "Error connecting to MTP device, couldn't get device free space";
return -1; return -1;
} }
LIBMTP_devicestorage_t* storage = connection.device()->storage; LIBMTP_devicestorage_t* storage = connection.device()->storage;
@ -319,7 +319,7 @@ quint64 MacDeviceLister::GetCapacity(const QUrl& url) {
QMutexLocker l(&libmtp_mutex_); QMutexLocker l(&libmtp_mutex_);
MtpConnection connection(url); MtpConnection connection(url);
if (!connection.is_valid()) { if (!connection.is_valid()) {
qWarning() << "Error connecting to MTP device, couldn't get device capacity"; qLog(Warning) << "Error connecting to MTP device, couldn't get device capacity";
return -1; return -1;
} }
LIBMTP_devicestorage_t* storage = connection.device()->storage; LIBMTP_devicestorage_t* storage = connection.device()->storage;
@ -794,7 +794,7 @@ void MacDeviceLister::UnmountDevice(const QString& serial) {
void MacDeviceLister::DiskUnmountCallback( void MacDeviceLister::DiskUnmountCallback(
DADiskRef disk, DADissenterRef dissenter, void* context) { DADiskRef disk, DADissenterRef dissenter, void* context) {
if (dissenter) { if (dissenter) {
qWarning() << "Another app blocked the unmount"; qLog(Warning) << "Another app blocked the unmount";
} else { } else {
DiskRemovedCallback(disk, context); DiskRemovedCallback(disk, context);
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "mtpconnection.h" #include "mtpconnection.h"
#include "core/logging.h"
#include <QRegExp> #include <QRegExp>
#include <QtDebug> #include <QtDebug>
@ -28,7 +29,7 @@ MtpConnection::MtpConnection(const QUrl& url)
QRegExp host_re("^usb-(\\d+)-(\\d+)$"); QRegExp host_re("^usb-(\\d+)-(\\d+)$");
if (host_re.indexIn(hostname) == -1) { if (host_re.indexIn(hostname) == -1) {
qWarning() << "Invalid MTP device:" << hostname; qLog(Warning) << "Invalid MTP device:" << hostname;
return; return;
} }
@ -55,7 +56,7 @@ MtpConnection::MtpConnection(const QUrl& url)
LIBMTP_raw_device_t* raw_devices = NULL; LIBMTP_raw_device_t* raw_devices = NULL;
LIBMTP_error_number_t err = LIBMTP_Detect_Raw_Devices(&raw_devices, &count); LIBMTP_error_number_t err = LIBMTP_Detect_Raw_Devices(&raw_devices, &count);
if (err != LIBMTP_ERROR_NONE) { if (err != LIBMTP_ERROR_NONE) {
qWarning() << "MTP error:" << err; qLog(Warning) << "MTP error:" << err;
return; return;
} }
@ -69,7 +70,7 @@ MtpConnection::MtpConnection(const QUrl& url)
} }
if (!raw_device) { if (!raw_device) {
qWarning() << "MTP device not found"; qLog(Warning) << "MTP device not found";
free(raw_devices); free(raw_devices);
return; return;
} }

View File

@ -19,6 +19,7 @@
#include "mtpconnection.h" #include "mtpconnection.h"
#include "mtpdevice.h" #include "mtpdevice.h"
#include "mtploader.h" #include "mtploader.h"
#include "core/logging.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "library/librarymodel.h" #include "library/librarymodel.h"
@ -177,7 +178,7 @@ bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType>* ret) {
QMutexLocker l(&db_busy_); QMutexLocker l(&db_busy_);
MtpConnection connection(url_); MtpConnection connection(url_);
if (!connection.is_valid()) { if (!connection.is_valid()) {
qWarning() << "Error connecting to MTP device, couldn't get list of supported filetypes"; qLog(Warning) << "Error connecting to MTP device, couldn't get list of supported filetypes";
return false; return false;
} }
@ -211,7 +212,7 @@ bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType>* ret, LIBMTP_mtpdevi
*ret << Song::Type_OggFlac; *ret << Song::Type_OggFlac;
break; break;
default: default:
qDebug() << "Unknown MTP file format" << qLog(Error) << "Unknown MTP file format" <<
LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t(list[i])); LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t(list[i]));
break; break;
} }

View File

@ -21,6 +21,7 @@
#include "wmdmloader.h" #include "wmdmloader.h"
#include "wmdmprogress.h" #include "wmdmprogress.h"
#include "wmdmthread.h" #include "wmdmthread.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "library/librarymodel.h" #include "library/librarymodel.h"
@ -133,7 +134,7 @@ bool WmdmDevice::CopyToStorage(const CopyJob& job) {
metadata_iface, metadata_iface,
NULL, // data NULL, // data
&new_storage)) { &new_storage)) {
qWarning() << "Couldn't copy file to WMDM device"; qLog(Warning) << "Couldn't copy file to WMDM device";
metadata_iface->Release(); metadata_iface->Release();
return false; return false;
} }
@ -244,7 +245,7 @@ bool WmdmDevice::GetSupportedFiletypes(QList<Song::FileType>* ret, IWMDMDevice*
if (device->GetFormatSupport( if (device->GetFormatSupport(
&formats, &format_count, &mime_types, &mime_count)) { &formats, &format_count, &mime_types, &mime_count)) {
qWarning() << "Unable to get a list of supported formats for device"; qLog(Warning) << "Unable to get a list of supported formats for device";
return false; return false;
} }

View File

@ -19,6 +19,7 @@
#include "wmdmlister.h" #include "wmdmlister.h"
#include "wmdmthread.h" #include "wmdmthread.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include <objbase.h> #include <objbase.h>
@ -73,7 +74,7 @@ void WmdmLister::Init() {
// Fetch the initial list of devices // Fetch the initial list of devices
IWMDMEnumDevice* device_it = NULL; IWMDMEnumDevice* device_it = NULL;
if (thread_->manager()->EnumDevices2(&device_it)) { if (thread_->manager()->EnumDevices2(&device_it)) {
qWarning() << "Error querying WMDM devices"; qLog(Warning) << "Error querying WMDM devices";
return; return;
} }
@ -87,7 +88,7 @@ void WmdmLister::Init() {
break; break;
if (device->QueryInterface(IID_IWMDMDevice2, (void**)&device2)) { if (device->QueryInterface(IID_IWMDMDevice2, (void**)&device2)) {
qWarning() << "Error getting IWMDMDevice2 from device"; qLog(Warning) << "Error getting IWMDMDevice2 from device";
device->Release(); device->Release();
continue; continue;
} }
@ -193,7 +194,7 @@ WmdmLister::DeviceInfo WmdmLister::ReadDeviceInfo(IWMDMDevice2* device) {
if (storage_it->Next(1, &storage, &storage_fetched) == S_OK) { if (storage_it->Next(1, &storage, &storage_fetched) == S_OK) {
if (storage->QueryInterface(IID_IWMDMStorage2, (void**)&ret.storage_)) { if (storage->QueryInterface(IID_IWMDMStorage2, (void**)&ret.storage_)) {
qWarning() << "Error getting IWMDMStorage2 from storage"; qLog(Warning) << "Error getting IWMDMStorage2 from storage";
} else { } else {
// Get free space information // Get free space information
UpdateFreeSpace(&ret); UpdateFreeSpace(&ret);
@ -260,7 +261,7 @@ void WmdmLister::GuessDriveLetter(DeviceInfo* info) {
if (!GetVolumeInformationW(volume_path, name, MAX_PATH, if (!GetVolumeInformationW(volume_path, name, MAX_PATH,
&serial, NULL, NULL, type, MAX_PATH)) { &serial, NULL, NULL, type, MAX_PATH)) {
qWarning() << "Error getting volume information for" << qLog(Warning) << "Error getting volume information for" <<
QString::fromWCharArray(volume_path); QString::fromWCharArray(volume_path);
} else { } else {
if (name.ToString() == info->name_ && name.characters() != 0) { if (name.ToString() == info->name_ && name.characters() != 0) {
@ -297,7 +298,7 @@ bool WmdmLister::CheckDriveLetter(DeviceInfo* info, const QString& drive) {
NULL, // flags NULL, // flags
type, MAX_PATH // fat or ntfs type, MAX_PATH // fat or ntfs
)) { )) {
qWarning() << "Error getting volume information for" << drive; qLog(Warning) << "Error getting volume information for" << drive;
return false; return false;
} else { } else {
qDebug() << "Validated drive letter" << drive; qDebug() << "Validated drive letter" << drive;
@ -436,13 +437,13 @@ void WmdmLister::WMDMDeviceAdded(const QString& canonical_name) {
IWMDMDevice* device = NULL; IWMDMDevice* device = NULL;
if (thread_->manager()->GetDeviceFromCanonicalName(name, &device)) { if (thread_->manager()->GetDeviceFromCanonicalName(name, &device)) {
qWarning() << "Error in GetDeviceFromCanonicalName for" << canonical_name; qLog(Warning) << "Error in GetDeviceFromCanonicalName for" << canonical_name;
return; return;
} }
IWMDMDevice2* device2 = NULL; IWMDMDevice2* device2 = NULL;
if (device->QueryInterface(IID_IWMDMDevice2, (void**) &device2)) { if (device->QueryInterface(IID_IWMDMDevice2, (void**) &device2)) {
qWarning() << "Error getting IWMDMDevice2 from device"; qLog(Warning) << "Error getting IWMDMDevice2 from device";
device->Release(); device->Release();
return; return;
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "wmdmthread.h" #include "wmdmthread.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include <mswmdm.h> #include <mswmdm.h>
@ -39,26 +40,26 @@ WmdmThread::WmdmThread()
IComponentAuthenticate* auth; IComponentAuthenticate* auth;
if (CoCreateInstance(CLSID_MediaDevMgr, NULL, CLSCTX_ALL, if (CoCreateInstance(CLSID_MediaDevMgr, NULL, CLSCTX_ALL,
IID_IComponentAuthenticate, (void**) &auth)) { IID_IComponentAuthenticate, (void**) &auth)) {
qWarning() << "Error creating the IComponentAuthenticate interface"; qLog(Warning) << "Error creating the IComponentAuthenticate interface";
return; return;
} }
sac_ = CSecureChannelClient_New(); sac_ = CSecureChannelClient_New();
if (CSecureChannelClient_SetCertificate( if (CSecureChannelClient_SetCertificate(
sac_, SAC_CERT_V1, abCert, sizeof(abCert), abPVK, sizeof(abPVK))) { sac_, SAC_CERT_V1, abCert, sizeof(abCert), abPVK, sizeof(abPVK))) {
qWarning() << "Error setting SAC certificate"; qLog(Warning) << "Error setting SAC certificate";
return; return;
} }
CSecureChannelClient_SetInterface(sac_, auth); CSecureChannelClient_SetInterface(sac_, auth);
if (CSecureChannelClient_Authenticate(sac_, SAC_PROTOCOL_V1)) { if (CSecureChannelClient_Authenticate(sac_, SAC_PROTOCOL_V1)) {
qWarning() << "Error authenticating with SAC"; qLog(Warning) << "Error authenticating with SAC";
return; return;
} }
// Create the device manager // Create the device manager
if (auth->QueryInterface(IID_IWMDeviceManager2, (void**)&device_manager_)) { if (auth->QueryInterface(IID_IWMDeviceManager2, (void**)&device_manager_)) {
qWarning() << "Error creating WMDM device manager"; qLog(Warning) << "Error creating WMDM device manager";
return; return;
} }
} }
@ -83,7 +84,7 @@ IWMDMDevice* WmdmThread::GetDeviceByCanonicalName(const QString& device_name) {
IWMDMDevice* device = NULL; IWMDMDevice* device = NULL;
if (device_manager_->GetDeviceFromCanonicalName(name, &device)) { if (device_manager_->GetDeviceFromCanonicalName(name, &device)) {
qWarning() << "Error in GetDeviceFromCanonicalName for" << device_name; qLog(Warning) << "Error in GetDeviceFromCanonicalName for" << device_name;
return NULL; return NULL;
} }

View File

@ -24,6 +24,7 @@
#include "config.h" #include "config.h"
#include "gstengine.h" #include "gstengine.h"
#include "gstenginepipeline.h" #include "gstenginepipeline.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#ifdef HAVE_IMOBILEDEVICE #ifdef HAVE_IMOBILEDEVICE
@ -204,7 +205,7 @@ void GstEngine::ConsumeBuffer(GstBuffer* buffer, int pipeline_id) {
if (!QMetaObject::invokeMethod(this, "AddBufferToScope", if (!QMetaObject::invokeMethod(this, "AddBufferToScope",
Q_ARG(GstBuffer*, buffer), Q_ARG(GstBuffer*, buffer),
Q_ARG(int, pipeline_id))) { Q_ARG(int, pipeline_id))) {
qWarning() << "Failed to invoke AddBufferToScope on GstEngine"; qLog(Warning) << "Failed to invoke AddBufferToScope on GstEngine";
} }
} }
@ -419,14 +420,14 @@ void GstEngine::PlayDone() {
// Failure, but we got a redirection URL - try loading that instead // Failure, but we got a redirection URL - try loading that instead
QUrl redirect_url = current_pipeline_->redirect_url(); QUrl redirect_url = current_pipeline_->redirect_url();
if (!redirect_url.isEmpty() && redirect_url != current_pipeline_->url()) { if (!redirect_url.isEmpty() && redirect_url != current_pipeline_->url()) {
qDebug() << "Redirecting to" << redirect_url; qLog(Info) << "Redirecting to" << redirect_url;
current_pipeline_ = CreatePipeline(redirect_url, end_nanosec_); current_pipeline_ = CreatePipeline(redirect_url, end_nanosec_);
Play(offset_nanosec); Play(offset_nanosec);
return; return;
} }
// Failure - give up // Failure - give up
qWarning() << "Could not set thread to PLAYING."; qLog(Warning) << "Could not set thread to PLAYING.";
current_pipeline_.reset(); current_pipeline_.reset();
return; return;
} }
@ -511,7 +512,7 @@ void GstEngine::SeekNow() {
if (current_pipeline_->Seek(seek_pos_)) if (current_pipeline_->Seek(seek_pos_))
ClearScopeBuffers(); ClearScopeBuffers();
else else
qDebug() << "Seek failed"; qLog(Warning) << "Seek failed";
} }
void GstEngine::SetEqualizerEnabled(bool enabled) { void GstEngine::SetEqualizerEnabled(bool enabled) {
@ -581,7 +582,7 @@ void GstEngine::HandlePipelineError(int pipeline_id, const QString& message,
if (!current_pipeline_.get() || current_pipeline_->id() != pipeline_id) if (!current_pipeline_.get() || current_pipeline_->id() != pipeline_id)
return; return;
qWarning() << "Gstreamer error:" << message; qLog(Warning) << "Gstreamer error:" << message;
current_pipeline_.reset(); current_pipeline_.reset();
@ -790,7 +791,7 @@ void GstEngine::BackgroundStreamPlayDone() {
GstStateChangeReturn ret = watcher->result(); GstStateChangeReturn ret = watcher->result();
if (ret == GST_STATE_CHANGE_FAILURE) { if (ret == GST_STATE_CHANGE_FAILURE) {
qWarning() << "Could not set thread to PLAYING."; qLog(Warning) << "Could not set thread to PLAYING.";
background_streams_.remove(stream_id); background_streams_.remove(stream_id);
} }
} }

View File

@ -17,12 +17,12 @@
#include <limits> #include <limits>
#include "gstelementdeleter.h"
#include "gstenginepipeline.h"
#include "gstengine.h"
#include "bufferconsumer.h" #include "bufferconsumer.h"
#include "gstelementdeleter.h"
#include "gstengine.h"
#include "gstenginepipeline.h"
#include "core/logging.h"
#include <QDebug>
#include <QtConcurrentRun> #include <QtConcurrentRun>
const int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000; const int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000;
@ -142,7 +142,7 @@ GstElement* GstEnginePipeline::CreateDecodeBinFromString(const char* pipeline) {
int code = error->code; int code = error->code;
g_error_free(error); g_error_free(error);
qWarning() << message; qLog(Warning) << message;
emit Error(id(), message, domain, code); emit Error(id(), message, domain, code);
return NULL; return NULL;
@ -287,6 +287,8 @@ GstEnginePipeline::~GstEnginePipeline() {
gboolean GstEnginePipeline::BusCallback(GstBus*, GstMessage* msg, gpointer self) { gboolean GstEnginePipeline::BusCallback(GstBus*, GstMessage* msg, gpointer self) {
GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);
qLog(Debug) << instance->id() << "bus message" << GST_MESSAGE_TYPE_NAME(msg);
switch (GST_MESSAGE_TYPE(msg)) { switch (GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_ERROR: case GST_MESSAGE_ERROR:
instance->ErrorMessageReceived(msg); instance->ErrorMessageReceived(msg);
@ -310,6 +312,8 @@ gboolean GstEnginePipeline::BusCallback(GstBus*, GstMessage* msg, gpointer self)
GstBusSyncReply GstEnginePipeline::BusCallbackSync(GstBus*, GstMessage* msg, gpointer self) { GstBusSyncReply GstEnginePipeline::BusCallbackSync(GstBus*, GstMessage* msg, gpointer self) {
GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);
qLog(Debug) << instance->id() << "sync bus message" << GST_MESSAGE_TYPE_NAME(msg);
switch (GST_MESSAGE_TYPE(msg)) { switch (GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_EOS: case GST_MESSAGE_EOS:
emit instance->EndOfStreamReached(instance->id(), false); emit instance->EndOfStreamReached(instance->id(), false);
@ -371,7 +375,8 @@ void GstEnginePipeline::ErrorMessageReceived(GstMessage* msg) {
return; return;
} }
qDebug() << debugstr; qLog(Error) << id() << debugstr;
emit Error(id(), message, domain, code); emit Error(id(), message, domain, code);
} }
@ -434,7 +439,7 @@ void GstEnginePipeline::NewPadCallback(GstElement*, GstPad* pad, gpointer self)
GstPad* const audiopad = gst_element_get_pad(instance->audiobin_, "sink"); GstPad* const audiopad = gst_element_get_pad(instance->audiobin_, "sink");
if (GST_PAD_IS_LINKED(audiopad)) { if (GST_PAD_IS_LINKED(audiopad)) {
qDebug() << "audiopad is already linked. Unlinking old pad."; qLog(Warning) << instance->id() << "audiopad is already linked, unlinking old pad";
gst_pad_unlink(audiopad, GST_PAD_PEER(audiopad)); gst_pad_unlink(audiopad, GST_PAD_PEER(audiopad));
} }
@ -503,6 +508,8 @@ bool GstEnginePipeline::HandoffCallback(GstPad*, GstBuffer* buf, gpointer self)
bool GstEnginePipeline::EventHandoffCallback(GstPad*, GstEvent* e, gpointer self) { bool GstEnginePipeline::EventHandoffCallback(GstPad*, GstEvent* e, gpointer self) {
GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);
qLog(Debug) << instance->id() << "event" << GST_EVENT_TYPE_NAME(e);
if (GST_EVENT_TYPE(e) == GST_EVENT_NEWSEGMENT && !instance->segment_start_received_) { if (GST_EVENT_TYPE(e) == GST_EVENT_NEWSEGMENT && !instance->segment_start_received_) {
// The segment start time is used to calculate the proper offset of data // The segment start time is used to calculate the proper offset of data
// buffers from the start of the stream // buffers from the start of the stream

View File

@ -17,6 +17,7 @@
#include "librarywatcher.h" #include "librarywatcher.h"
#include "librarybackend.h" #include "librarybackend.h"
#include "core/logging.h"
#include "core/taskmanager.h" #include "core/taskmanager.h"
#include "playlistparsers/cueparser.h" #include "playlistparsers/cueparser.h"
@ -328,7 +329,7 @@ void LibraryWatcher::ScanSubdirectory(
// the song's changed - reread the metadata from file // the song's changed - reread the metadata from file
if (t->ignores_mtime() || changed) { if (t->ignores_mtime() || changed) {
qDebug() << file << "changed"; qLog(Debug) << file << "changed";
// if cue associated... // if cue associated...
if(!cue_deleted && (matching_song.has_cue() || cue_added)) { if(!cue_deleted && (matching_song.has_cue() || cue_added)) {
@ -346,7 +347,7 @@ void LibraryWatcher::ScanSubdirectory(
continue; continue;
} }
qDebug() << file << "created"; qLog(Debug) << file << "created";
// choose an image for the song(s) // choose an image for the song(s)
QString image = ImageForSong(file, album_art); QString image = ImageForSong(file, album_art);
@ -363,7 +364,7 @@ void LibraryWatcher::ScanSubdirectory(
// Look for deleted songs // Look for deleted songs
foreach (const Song& song, songs_in_db) { foreach (const Song& song, songs_in_db) {
if (!files_on_disk.contains(song.filename())) { if (!files_on_disk.contains(song.filename())) {
qDebug() << "Song deleted from disk:" << song.filename(); qLog(Debug) << "Song deleted from disk:" << song.filename();
t->deleted_songs << song; t->deleted_songs << song;
} }
} }
@ -510,7 +511,7 @@ void LibraryWatcher::PreserveUserSetData(const QString& file, const QString& ima
out->set_art_manual(matching_song.art_manual()); out->set_art_manual(matching_song.art_manual());
if (!matching_song.IsMetadataEqual(*out)) { if (!matching_song.IsMetadataEqual(*out)) {
qDebug() << file << "metadata changed"; qLog(Debug) << file << "metadata changed";
// Update the song in the DB // Update the song in the DB
t->new_songs << *out; t->new_songs << *out;
@ -572,7 +573,7 @@ void LibraryWatcher::DirectoryChanged(const QString &subdir) {
dir = info.dir; dir = info.dir;
} }
qDebug() << "Subdir" << subdir << "changed under directory" << dir.path << "id" << dir.id; qLog(Debug) << "Subdir" << subdir << "changed under directory" << dir.path << "id" << dir.id;
// Queue the subdir for rescanning // Queue the subdir for rescanning
if (!rescan_queue_[dir.id].contains(subdir)) if (!rescan_queue_[dir.id].contains(subdir))

View File

@ -28,6 +28,7 @@
#include "core/crashreporting.h" #include "core/crashreporting.h"
#include "core/database.h" #include "core/database.h"
#include "core/encoding.h" #include "core/encoding.h"
#include "core/logging.h"
#include "core/mac_startup.h" #include "core/mac_startup.h"
#include "core/network.h" #include "core/network.h"
#include "core/networkproxyfactory.h" #include "core/networkproxyfactory.h"
@ -123,13 +124,6 @@ void LoadTranslation(const QString& prefix, const QString& path,
delete t; delete t;
} }
void GLog(const gchar* domain,
GLogLevelFlags level,
const gchar* message,
gpointer user_data) {
qDebug() << "GLOG" << message;
}
#ifdef HAVE_REMOTE #ifdef HAVE_REMOTE
#include <xrme/connection.h> #include <xrme/connection.h>
#include "remote/icesession.h" #include "remote/icesession.h"
@ -162,7 +156,7 @@ int main(int argc, char *argv[]) {
int ret = setrlimit(RLIMIT_NOFILE, &limit); int ret = setrlimit(RLIMIT_NOFILE, &limit);
if (ret == 0) { if (ret == 0) {
qDebug() << "Max fd:" << max_fd; qLog(Debug) << "Max fd:" << max_fd;
} }
} }
#endif #endif
@ -194,8 +188,6 @@ int main(int argc, char *argv[]) {
g_type_init(); g_type_init();
g_set_application_name(QCoreApplication::applicationName().toLocal8Bit()); g_set_application_name(QCoreApplication::applicationName().toLocal8Bit());
g_log_set_default_handler(&GLog, NULL);
qRegisterMetaType<Directory>("Directory"); qRegisterMetaType<Directory>("Directory");
qRegisterMetaType<DirectoryList>("DirectoryList"); qRegisterMetaType<DirectoryList>("DirectoryList");
qRegisterMetaType<Subdirectory>("Subdirectory"); qRegisterMetaType<Subdirectory>("Subdirectory");
@ -244,7 +236,7 @@ int main(int argc, char *argv[]) {
if (a.isRunning()) { if (a.isRunning()) {
if (options.is_empty()) { if (options.is_empty()) {
qDebug() << "Clementine is already running - activating existing window"; qLog(Info) << "Clementine is already running - activating existing window";
} }
if (a.sendMessage(options.Serialize(), 5000)) { if (a.sendMessage(options.Serialize(), 5000)) {
return 0; return 0;
@ -319,6 +311,10 @@ int main(int argc, char *argv[]) {
} }
#endif #endif
// Initialise logging
logging::Init();
logging::SetLevels(options.log_levels());
QtSingleApplication a(argc, argv); QtSingleApplication a(argc, argv);
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
QCoreApplication::setLibraryPaths( QCoreApplication::setLibraryPaths(

View File

@ -16,6 +16,7 @@
*/ */
#include "fingerprinter.h" #include "fingerprinter.h"
#include "core/logging.h"
#include <QDir> #include <QDir>
#include <QEventLoop> #include <QEventLoop>
@ -52,7 +53,7 @@ GstElement* Fingerprinter::CreateElement(const QString &factory_name,
gst_bin_add(GST_BIN(bin), ret); gst_bin_add(GST_BIN(bin), ret);
if (!ret) { if (!ret) {
qDebug() << "Couldn't create the gstreamer element" << factory_name; qLog(Warning) << "Couldn't create the gstreamer element" << factory_name;
} }
return ret; return ret;
@ -102,7 +103,7 @@ void Fingerprinter::NewPadCallback(GstElement*, GstPad* pad, gboolean, gpointer
GstPad* const audiopad = gst_element_get_pad(instance->convert_element_, "sink"); GstPad* const audiopad = gst_element_get_pad(instance->convert_element_, "sink");
if (GST_PAD_IS_LINKED(audiopad)) { if (GST_PAD_IS_LINKED(audiopad)) {
qDebug() << "audiopad is already linked. Unlinking old pad."; qLog(Warning) << "audiopad is already linked, unlinking old pad";
gst_pad_unlink(audiopad, GST_PAD_PEER(audiopad)); gst_pad_unlink(audiopad, GST_PAD_PEER(audiopad));
} }
@ -120,7 +121,7 @@ void Fingerprinter::ReportError(GstMessage* msg) {
g_error_free(error); g_error_free(error);
free(debugs); free(debugs);
qDebug() << "Fingerprinter: Error processing" << filename_ << ":" << message; qLog(Error) << "Error processing" << filename_ << ":" << message;
} }
gboolean Fingerprinter::BusCallback(GstBus*, GstMessage* msg, gpointer data) { gboolean Fingerprinter::BusCallback(GstBus*, GstMessage* msg, gpointer data) {

View File

@ -24,6 +24,7 @@
#include "songloaderinserter.h" #include "songloaderinserter.h"
#include "songmimedata.h" #include "songmimedata.h"
#include "songplaylistitem.h" #include "songplaylistitem.h"
#include "core/logging.h"
#include "core/modelfuturewatcher.h" #include "core/modelfuturewatcher.h"
#include "library/library.h" #include "library/library.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
@ -954,7 +955,7 @@ void Playlist::InsertRadioStations(const RadioModel* model,
} }
void Playlist::UpdateItems(const SongList& songs) { void Playlist::UpdateItems(const SongList& songs) {
qDebug() << "Updating playlist with new tracks' info"; qLog(Debug) << "Updating playlist with new tracks' info";
foreach (const Song& song, songs) { foreach (const Song& song, songs) {
// Update current items list // Update current items list
for (int i=0; i<items_.size(); i++) { for (int i=0; i<items_.size(); i++) {

View File

@ -17,6 +17,7 @@
#include "playlistdelegates.h" #include "playlistdelegates.h"
#include "queue.h" #include "queue.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "widgets/trackslider.h" #include "widgets/trackslider.h"
@ -376,7 +377,7 @@ QString TagCompletionModel::database_column(Playlist::Column column) {
case Playlist::Column_Composer: return "composer"; case Playlist::Column_Composer: return "composer";
case Playlist::Column_Genre: return "genre"; case Playlist::Column_Genre: return "genre";
default: default:
qWarning() << __PRETTY_FUNCTION__ << "Unknown column" << column; qLog(Warning) << "Unknown column" << column;
return QString(); return QString();
} }
} }

View File

@ -17,6 +17,7 @@
#include "playlistitem.h" #include "playlistitem.h"
#include "songplaylistitem.h" #include "songplaylistitem.h"
#include "core/logging.h"
#include "library/library.h" #include "library/library.h"
#include "library/libraryplaylistitem.h" #include "library/libraryplaylistitem.h"
#include "radio/jamendoplaylistitem.h" #include "radio/jamendoplaylistitem.h"
@ -46,7 +47,7 @@ PlaylistItem* PlaylistItem::NewFromType(const QString& type) {
if (type == "Radio") if (type == "Radio")
return new RadioPlaylistItem(type); return new RadioPlaylistItem(type);
qWarning() << "Invalid PlaylistItem type:" << type; qLog(Warning) << "Invalid PlaylistItem type:" << type;
return NULL; return NULL;
} }
@ -58,7 +59,7 @@ PlaylistItem* PlaylistItem::NewFromSongsTable(const QString& table, const Song&
if (table == JamendoService::kSongsTable) if (table == JamendoService::kSongsTable)
return new JamendoPlaylistItem(song); return new JamendoPlaylistItem(song);
qWarning() << "Invalid PlaylistItem songs table:" << table; qLog(Warning) << "Invalid PlaylistItem songs table:" << table;
return NULL; return NULL;
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "asxiniparser.h" #include "asxiniparser.h"
#include "core/logging.h"
#include <QTextStream> #include <QTextStream>
#include <QtDebug> #include <QtDebug>
@ -41,7 +42,7 @@ SongList AsxIniParser::Load(QIODevice *device, const QString& playlist_path, con
if (key.startsWith("ref")) { if (key.startsWith("ref")) {
Song song; Song song;
if (!ParseTrackLocation(value, dir, &song)) if (!ParseTrackLocation(value, dir, &song))
qWarning() << "Failed to parse location: " << value; qLog(Warning) << "Failed to parse location: " << value;
// Load the song from the library if it's there. // Load the song from the library if it's there.
Song library_song = LoadLibrarySong(song.filename()); Song library_song = LoadLibrarySong(song.filename());

View File

@ -16,6 +16,7 @@
*/ */
#include "cueparser.h" #include "cueparser.h"
#include "core/logging.h"
#include <QBuffer> #include <QBuffer>
#include <QDateTime> #include <QDateTime>
@ -114,7 +115,7 @@ SongList CueParser::Load(QIODevice* device, const QString& playlist_path, const
} while(!(line = text_stream.readLine()).isNull()); } while(!(line = text_stream.readLine()).isNull());
if(line.isNull()) { if(line.isNull()) {
qWarning() << "the .cue file from " << dir_path << " defines no tracks!"; qLog(Warning) << "the .cue file from " << dir_path << " defines no tracks!";
return ret; return ret;
} }
@ -208,7 +209,7 @@ SongList CueParser::Load(QIODevice* device, const QString& playlist_path, const
Song current; Song current;
if (!ParseTrackLocation(entry.file, dir, &current)) { if (!ParseTrackLocation(entry.file, dir, &current)) {
qWarning() << "failed to parse location in .cue file from " << dir_path; qLog(Warning) << "failed to parse location in .cue file from " << dir_path;
} else { } else {
// look for the section in library // look for the section in library
Song song = LoadLibrarySong(current.filename(), IndexToMarker(entry.index)); Song song = LoadLibrarySong(current.filename(), IndexToMarker(entry.index));

View File

@ -16,6 +16,7 @@
*/ */
#include "m3uparser.h" #include "m3uparser.h"
#include "core/logging.h"
#include <QBuffer> #include <QBuffer>
#include <QtDebug> #include <QtDebug>
@ -39,7 +40,6 @@ SongList M3UParser::Load(QIODevice* device, const QString& playlist_path, const
buffer.open(QIODevice::ReadOnly); buffer.open(QIODevice::ReadOnly);
QString line = QString::fromUtf8(buffer.readLine()).trimmed(); QString line = QString::fromUtf8(buffer.readLine()).trimmed();
qDebug() << line;
if (line.startsWith("#EXTM3U")) { if (line.startsWith("#EXTM3U")) {
// This is in extended M3U format. // This is in extended M3U format.
type = EXTENDED; type = EXTENDED;
@ -47,12 +47,11 @@ SongList M3UParser::Load(QIODevice* device, const QString& playlist_path, const
} }
forever { forever {
qDebug() << line;
if (line.startsWith('#')) { if (line.startsWith('#')) {
// Extended info or comment. // Extended info or comment.
if (type == EXTENDED && line.startsWith("#EXT")) { if (type == EXTENDED && line.startsWith("#EXT")) {
if (!ParseMetadata(line, &current_metadata)) { if (!ParseMetadata(line, &current_metadata)) {
qWarning() << "Failed to parse metadata: " << line; qLog(Warning) << "Failed to parse metadata: " << line;
continue; continue;
} }
} }
@ -61,7 +60,7 @@ SongList M3UParser::Load(QIODevice* device, const QString& playlist_path, const
// Track location. // Track location.
if (!ParseTrackLocation(line, dir, &song)) { if (!ParseTrackLocation(line, dir, &song)) {
qWarning() << "Failed to parse location: " << line; qLog(Warning) << "Failed to parse location: " << line;
} else { } else {
// Load the song from the library if it's there. // Load the song from the library if it's there.
Song library_song = LoadLibrarySong(song.filename()); Song library_song = LoadLibrarySong(song.filename());

View File

@ -15,13 +15,14 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>. along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "playlistparser.h"
#include "xspfparser.h"
#include "m3uparser.h"
#include "plsparser.h"
#include "cueparser.h"
#include "asxparser.h" #include "asxparser.h"
#include "asxiniparser.h" #include "asxiniparser.h"
#include "cueparser.h"
#include "m3uparser.h"
#include "playlistparser.h"
#include "plsparser.h"
#include "xspfparser.h"
#include "core/logging.h"
#include <QtDebug> #include <QtDebug>
@ -105,7 +106,7 @@ SongList PlaylistParser::LoadFromFile(const QString& filename) const {
// Find a parser that supports this file extension // Find a parser that supports this file extension
ParserBase* parser = ParserForExtension(info.suffix()); ParserBase* parser = ParserForExtension(info.suffix());
if (!parser) { if (!parser) {
qWarning() << "Unknown filetype:" << filename; qLog(Warning) << "Unknown filetype:" << filename;
return SongList(); return SongList();
} }
@ -134,7 +135,7 @@ void PlaylistParser::Save(const SongList& songs, const QString& filename) const
// Find a parser that supports this file extension // Find a parser that supports this file extension
ParserBase* parser = ParserForExtension(info.suffix()); ParserBase* parser = ParserForExtension(info.suffix());
if (!parser) { if (!parser) {
qWarning() << "Unknown filetype:" << filename; qLog(Warning) << "Unknown filetype:" << filename;
return; return;
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "plsparser.h" #include "plsparser.h"
#include "core/logging.h"
#include <QTextStream> #include <QTextStream>
#include <QtDebug> #include <QtDebug>
@ -40,7 +41,7 @@ SongList PLSParser::Load(QIODevice *device, const QString& playlist_path, const
if (key.startsWith("file")) { if (key.startsWith("file")) {
if (!ParseTrackLocation(value, dir, &songs[n])) if (!ParseTrackLocation(value, dir, &songs[n]))
qWarning() << "Failed to parse location: " << value; qLog(Warning) << "Failed to parse location: " << value;
// Load the song from the library if it's there. // Load the song from the library if it's there.
Song library_song = LoadLibrarySong(songs[n].filename()); Song library_song = LoadLibrarySong(songs[n].filename());

View File

@ -5,6 +5,7 @@
#include <QHttpRequestHeader> #include <QHttpRequestHeader>
#include <QtDebug> #include <QtDebug>
#include "core/logging.h"
#include "core/network.h" #include "core/network.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "radio/jamendoplaylistitem.h" #include "radio/jamendoplaylistitem.h"
@ -106,7 +107,7 @@ void JamendoDynamicPlaylist::Fetch() {
} }
if (http.error() != QHttp::NoError) { if (http.error() != QHttp::NoError) {
qWarning() << "HTTP error returned from Jamendo:" << http.errorString() qLog(Warning) << "HTTP error returned from Jamendo:" << http.errorString()
<< ", url:" << url.toString(); << ", url:" << url.toString();
return; return;
} }
@ -119,7 +120,7 @@ void JamendoDynamicPlaylist::Fetch() {
lines, JamendoService::kTrackIdsTable, JamendoService::kTrackIdsColumn); lines, JamendoService::kTrackIdsTable, JamendoService::kTrackIdsColumn);
if (songs.empty()) { if (songs.empty()) {
qWarning() << "No songs returned from Jamendo:" qLog(Warning) << "No songs returned from Jamendo:"
<< url.toString(); << url.toString();
return; return;
} }

View File

@ -28,6 +28,7 @@
#include "qtiocompressor.h" #include "qtiocompressor.h"
#include "core/database.h" #include "core/database.h"
#include "core/logging.h"
#include "core/mergedproxymodel.h" #include "core/mergedproxymodel.h"
#include "core/network.h" #include "core/network.h"
#include "core/scopedtransaction.h" #include "core/scopedtransaction.h"
@ -189,7 +190,7 @@ void JamendoService::DownloadDirectoryFinished() {
QtIOCompressor* gzip = new QtIOCompressor(reply); QtIOCompressor* gzip = new QtIOCompressor(reply);
gzip->setStreamFormat(QtIOCompressor::GzipFormat); gzip->setStreamFormat(QtIOCompressor::GzipFormat);
if (!gzip->open(QIODevice::ReadOnly)) { if (!gzip->open(QIODevice::ReadOnly)) {
qWarning() << "Jamendo library not in gzip format"; qLog(Warning) << "Jamendo library not in gzip format";
delete gzip; delete gzip;
return; return;
} }
@ -265,7 +266,7 @@ void JamendoService::InsertTrackIds(const TrackIdList& ids) const {
foreach (int id, ids) { foreach (int id, ids) {
insert.bindValue(":id", id); insert.bindValue(":id", id);
if (!insert.exec()) { if (!insert.exec()) {
qWarning() << "Query failed" << insert.lastQuery(); qLog(Warning) << "Query failed" << insert.lastQuery();
} }
} }

View File

@ -19,6 +19,7 @@
#include "lastfmstationdialog.h" #include "lastfmstationdialog.h"
#include "radiomodel.h" #include "radiomodel.h"
#include "radioplaylistitem.h" #include "radioplaylistitem.h"
#include "core/logging.h"
#include "core/song.h" #include "core/song.h"
#include "core/taskmanager.h" #include "core/taskmanager.h"
#include "ui/iconloader.h" #include "ui/iconloader.h"
@ -289,7 +290,7 @@ void LastFMService::AuthenticateReplyFinished() {
settings.setValue("Session", lastfm::ws::SessionKey); settings.setValue("Session", lastfm::ws::SessionKey);
settings.setValue("Subscriber", is_subscriber); settings.setValue("Subscriber", is_subscriber);
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
qDebug() << e.what(); qLog(Error) << e.what();
emit AuthenticationComplete(false); emit AuthenticationComplete(false);
return; return;
} }
@ -327,10 +328,10 @@ void LastFMService::UpdateSubscriberStatusFinished() {
QSettings settings; QSettings settings;
settings.beginGroup(kSettingsGroup); settings.beginGroup(kSettingsGroup);
settings.setValue("Subscriber", is_subscriber); settings.setValue("Subscriber", is_subscriber);
qDebug() << lastfm::ws::Username << "Subscriber status:" << is_subscriber; qLog(Info) << lastfm::ws::Username << "Subscriber status:" << is_subscriber;
emit UpdatedSubscriberStatus(is_subscriber); emit UpdatedSubscriberStatus(is_subscriber);
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
qDebug() << e.what(); qLog(Error) << e.what();
} }
} }
@ -482,7 +483,7 @@ void LastFMService::NowPlaying(const Song &song) {
lastfm::MutableTrack mtrack(last_track_); lastfm::MutableTrack mtrack(last_track_);
mtrack.setDuration(duration_secs); mtrack.setDuration(duration_secs);
qDebug() << "Scrobbling stream track" << mtrack.title() << "length" << duration_secs; qLog(Info) << "Scrobbling stream track" << mtrack.title() << "length" << duration_secs;
scrobbler_->cache(mtrack); scrobbler_->cache(mtrack);
scrobbler_->submit(); scrobbler_->submit();
@ -600,7 +601,7 @@ void LastFMService::RefreshFriendsFinished() {
throw std::runtime_error(""); throw std::runtime_error("");
#endif #endif
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
qDebug() << e.what(); qLog(Error) << e.what();
return; return;
} }
@ -629,7 +630,7 @@ void LastFMService::RefreshNeighboursFinished() {
throw std::runtime_error(""); throw std::runtime_error("");
#endif #endif
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
qDebug() << e.what(); qLog(Error) << e.what();
return; return;
} }
@ -760,7 +761,7 @@ void LastFMService::FetchMoreTracks() {
void LastFMService::FetchMoreTracksFinished() { void LastFMService::FetchMoreTracksFinished() {
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if (!reply) { if (!reply) {
qWarning() << "Invalid reply on radio.getPlaylist"; qLog(Warning) << "Invalid reply on radio.getPlaylist";
emit AsyncLoadFinished(PlaylistItem::SpecialLoadResult( emit AsyncLoadFinished(PlaylistItem::SpecialLoadResult(
PlaylistItem::SpecialLoadResult::NoMoreTracks, reply->url())); PlaylistItem::SpecialLoadResult::NoMoreTracks, reply->url()));
return; return;
@ -823,7 +824,7 @@ void LastFMService::Tune(const lastfm::RadioStation& station) {
void LastFMService::TuneFinished() { void LastFMService::TuneFinished() {
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if (!reply) { if (!reply) {
qWarning() << "Invalid reply on radio.tune"; qLog(Warning) << "Invalid reply on radio.tune";
emit AsyncLoadFinished(PlaylistItem::SpecialLoadResult( emit AsyncLoadFinished(PlaylistItem::SpecialLoadResult(
PlaylistItem::SpecialLoadResult::NoMoreTracks, reply->url())); PlaylistItem::SpecialLoadResult::NoMoreTracks, reply->url()));
return; return;

View File

@ -19,6 +19,7 @@
#include "magnatuneplaylistitem.h" #include "magnatuneplaylistitem.h"
#include "magnatuneservice.h" #include "magnatuneservice.h"
#include "radiomodel.h" #include "radiomodel.h"
#include "core/logging.h"
#include "core/mergedproxymodel.h" #include "core/mergedproxymodel.h"
#include "core/network.h" #include "core/network.h"
#include "core/song.h" #include "core/song.h"
@ -150,7 +151,7 @@ void MagnatuneService::ReloadDatabaseFinished() {
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
// TODO: Error handling // TODO: Error handling
qDebug() << reply->errorString(); qLog(Error) << reply->errorString();
return; return;
} }
@ -161,7 +162,7 @@ void MagnatuneService::ReloadDatabaseFinished() {
QtIOCompressor gzip(reply); QtIOCompressor gzip(reply);
gzip.setStreamFormat(QtIOCompressor::GzipFormat); gzip.setStreamFormat(QtIOCompressor::GzipFormat);
if (!gzip.open(QIODevice::ReadOnly)) { if (!gzip.open(QIODevice::ReadOnly)) {
qWarning() << "Error opening gzip stream"; qLog(Warning) << "Error opening gzip stream";
return; return;
} }

View File

@ -15,7 +15,6 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>. along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "core/mergedproxymodel.h"
#include "icecastservice.h" #include "icecastservice.h"
#include "jamendoservice.h" #include "jamendoservice.h"
#include "magnatuneservice.h" #include "magnatuneservice.h"
@ -24,6 +23,8 @@
#include "radioservice.h" #include "radioservice.h"
#include "savedradio.h" #include "savedradio.h"
#include "somafmservice.h" #include "somafmservice.h"
#include "core/logging.h"
#include "core/mergedproxymodel.h"
#ifdef HAVE_LIBLASTFM #ifdef HAVE_LIBLASTFM
#include "lastfmservice.h" #include "lastfmservice.h"
@ -61,7 +62,7 @@ RadioModel::RadioModel(BackgroundThread<Database>* db_thread,
void RadioModel::AddService(RadioService *service) { void RadioModel::AddService(RadioService *service) {
QStandardItem* root = service->CreateRootItem(); QStandardItem* root = service->CreateRootItem();
if (!root) { if (!root) {
qWarning() << "Radio service" << service->name() << "did not return a root item"; qLog(Warning) << "Radio service" << service->name() << "did not return a root item";
return; return;
} }

View File

@ -17,6 +17,7 @@
#include "somafmservice.h" #include "somafmservice.h"
#include "radiomodel.h" #include "radiomodel.h"
#include "core/logging.h"
#include "core/network.h" #include "core/network.h"
#include "core/taskmanager.h" #include "core/taskmanager.h"
#include "ui/iconloader.h" #include "ui/iconloader.h"
@ -103,7 +104,7 @@ void SomaFMService::LoadPlaylistFinished() {
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
// TODO: Error handling // TODO: Error handling
qDebug() << reply->errorString(); qLog(Error) << reply->errorString();
emit AsyncLoadFinished(PlaylistItem::SpecialLoadResult( emit AsyncLoadFinished(PlaylistItem::SpecialLoadResult(
PlaylistItem::SpecialLoadResult::NoMoreTracks, original_url)); PlaylistItem::SpecialLoadResult::NoMoreTracks, original_url));
return; return;
@ -138,7 +139,7 @@ void SomaFMService::RefreshChannelsFinished() {
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
// TODO: Error handling // TODO: Error handling
qDebug() << reply->errorString(); qLog(Error) << reply->errorString();
return; return;
} }

View File

@ -1,4 +1,5 @@
#include "icesession.h" #include "icesession.h"
#include "core/logging.h"
#include <QHostAddress> #include <QHostAddress>
@ -35,7 +36,7 @@ bool ICESession::Init() {
&ice_cb, &ice_cb,
&ice_instance_); &ice_instance_);
if (status != PJ_SUCCESS) { if (status != PJ_SUCCESS) {
qWarning() << "Failed to create ICE instance"; qLog(Warning) << "Failed to create ICE instance";
return false; return false;
} }
@ -147,7 +148,7 @@ void ICESession::StartNegotiation(const xrme::SIPInfo& session) {
candidates); candidates);
if (status != PJ_SUCCESS) { if (status != PJ_SUCCESS) {
qWarning() << "Start negotation failed"; qLog(Warning) << "Start negotation failed";
} else { } else {
qDebug() << "ICE negotiation started"; qDebug() << "ICE negotiation started";
} }

View File

@ -22,6 +22,7 @@
#include "pythonengine.h" #include "pythonengine.h"
#include "pythonscript.h" #include "pythonscript.h"
#include "sipAPIclementine.h" #include "sipAPIclementine.h"
#include "core/logging.h"
#include "covers/coverproviders.h" #include "covers/coverproviders.h"
#include "library/library.h" #include "library/library.h"
@ -214,7 +215,7 @@ void PythonEngine::RegisterNativeObject(QObject* object) {
PyFrameObject* frame = PyEval_GetFrame(); PyFrameObject* frame = PyEval_GetFrame();
if (!frame) { if (!frame) {
qWarning() << __PRETTY_FUNCTION__ << "unable to get stack frame"; qLog(Warning) << "unable to get stack frame";
return; return;
} }
while (frame->f_back) { while (frame->f_back) {
@ -224,7 +225,7 @@ void PythonEngine::RegisterNativeObject(QObject* object) {
PyObject* __package__ = PyMapping_GetItemString( PyObject* __package__ = PyMapping_GetItemString(
frame->f_globals, const_cast<char*>("__package__")); frame->f_globals, const_cast<char*>("__package__"));
if (!__package__) { if (!__package__) {
qWarning() << __PRETTY_FUNCTION__ << "unable to get __package__"; qLog(Warning) << "unable to get __package__";
return; return;
} }
@ -234,7 +235,7 @@ void PythonEngine::RegisterNativeObject(QObject* object) {
Script* script = FindScriptMatchingId(package); Script* script = FindScriptMatchingId(package);
if (!script) { if (!script) {
qWarning() << __PRETTY_FUNCTION__ << "unable to find script for package" << package; qLog(Warning) << "unable to find script for package" << package;
return; return;
} }

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include "scriptarchive.h" #include "scriptarchive.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include <QDir> #include <QDir>
@ -59,7 +60,7 @@ namespace {
if (bytes_read == ARCHIVE_FATAL || if (bytes_read == ARCHIVE_FATAL ||
bytes_read == ARCHIVE_WARN || bytes_read == ARCHIVE_WARN ||
bytes_read == ARCHIVE_RETRY) { bytes_read == ARCHIVE_RETRY) {
qWarning() << "Error reading archive:" << archive_error_string(in); qLog(Warning) << "Error reading archive:" << archive_error_string(in);
return; return;
} }
if (bytes_read == 0) { if (bytes_read == 0) {
@ -67,7 +68,7 @@ namespace {
} }
if (archive_write_data(out, buf, bytes_read) == -1) { if (archive_write_data(out, buf, bytes_read) == -1) {
qWarning() << "Error extracting archive:" << archive_error_string(out); qLog(Warning) << "Error extracting archive:" << archive_error_string(out);
return; return;
} }
} }

View File

@ -17,6 +17,7 @@
#include "languageengine.h" #include "languageengine.h"
#include "scriptinfo.h" #include "scriptinfo.h"
#include "core/logging.h"
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
@ -38,7 +39,7 @@ void ScriptInfo::InitFromDirectory(const ScriptManager* manager, const QString&
// Does the file exist? // Does the file exist?
if (!QFile::exists(ini_file)) { if (!QFile::exists(ini_file)) {
qWarning() << "Script definition file not found:" << ini_file; qLog(Warning) << "Script definition file not found:" << ini_file;
return; return;
} }
@ -52,7 +53,7 @@ void ScriptInfo::InitFromFile(const ScriptManager* manager,
// Open it // Open it
QSettings s(ini_file, QSettings::IniFormat); QSettings s(ini_file, QSettings::IniFormat);
if (!s.childGroups().contains(kIniSettingsGroup)) { if (!s.childGroups().contains(kIniSettingsGroup)) {
qWarning() << "Missing" << kIniSettingsGroup << "section in" << ini_file; qLog(Warning) << "Missing" << kIniSettingsGroup << "section in" << ini_file;
return; return;
} }
s.beginGroup(kIniSettingsGroup); s.beginGroup(kIniSettingsGroup);
@ -61,7 +62,7 @@ void ScriptInfo::InitFromFile(const ScriptManager* manager,
QString language_name = s.value("language").toString(); QString language_name = s.value("language").toString();
LanguageEngine* engine = manager->EngineForLanguage(language_name); LanguageEngine* engine = manager->EngineForLanguage(language_name);
if (!engine) { if (!engine) {
qWarning() << "Unknown language" << language_name << "in" << ini_file; qLog(Warning) << "Unknown language" << language_name << "in" << ini_file;
return; return;
} }
d->language_ = engine->language(); d->language_ = engine->language();

View File

@ -21,6 +21,7 @@
#include "scriptinterface.h" #include "scriptinterface.h"
#include "scriptmanager.h" #include "scriptmanager.h"
#include "uiinterface.h" #include "uiinterface.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#ifdef HAVE_SCRIPTING_PYTHON #ifdef HAVE_SCRIPTING_PYTHON
@ -61,7 +62,7 @@ ScriptManager::ScriptManager(QObject* parent)
QString local_path = Utilities::GetConfigPath(Utilities::Path_Scripts); QString local_path = Utilities::GetConfigPath(Utilities::Path_Scripts);
if (!QFile::exists(local_path)) { if (!QFile::exists(local_path)) {
if (!QDir().mkpath(local_path)) { if (!QDir().mkpath(local_path)) {
qWarning() << "Couldn't create directory" << local_path; qLog(Warning) << "Couldn't create directory" << local_path;
} }
} }
@ -112,7 +113,7 @@ void ScriptManager::MaybeAutoEnable(ScriptInfo* info) {
// Find an engine for it // Find an engine for it
LanguageEngine* engine = EngineForLanguage(info->language()); LanguageEngine* engine = EngineForLanguage(info->language());
if (!engine) { if (!engine) {
qWarning() << "Unknown language in" << info->path(); qLog(Warning) << "Unknown language in" << info->path();
return; return;
} }
@ -149,7 +150,7 @@ QMap<QString, ScriptInfo> ScriptManager::LoadAllScriptInfo() const {
ScriptInfo info; ScriptInfo info;
info.InitFromDirectory(this, path); info.InitFromDirectory(this, path);
if (!info.is_valid()) { if (!info.is_valid()) {
qWarning() << "Not a valid Clementine script directory, ignoring:" qLog(Warning) << "Not a valid Clementine script directory, ignoring:"
<< path; << path;
continue; continue;
} }
@ -250,7 +251,7 @@ void ScriptManager::Enable(const QModelIndex& index) {
// Find an engine for it // Find an engine for it
LanguageEngine* engine = EngineForLanguage(info->language()); LanguageEngine* engine = EngineForLanguage(info->language());
if (!engine) { if (!engine) {
qWarning() << "Unknown language in" << info->path(); qLog(Warning) << "Unknown language in" << info->path();
return; return;
} }
@ -308,7 +309,7 @@ void ScriptManager::AddLogLine(const QString& who, const QString& message, bool
log_lines_plain_ << plain; log_lines_plain_ << plain;
emit LogLineAdded(html); emit LogLineAdded(html);
qDebug() << plain.toLocal8Bit().constData(); qLog(Info) << plain.toLocal8Bit().constData();
} }
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "uiinterface.h" #include "uiinterface.h"
#include "core/logging.h"
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
@ -28,8 +29,7 @@ UIInterface::UIInterface(QObject* parent)
void UIInterface::RegisterActionLocation(const QString& id, QMenu* menu, QAction* before) { void UIInterface::RegisterActionLocation(const QString& id, QMenu* menu, QAction* before) {
if (locations_.contains(id)) { if (locations_.contains(id)) {
qDebug() << __PRETTY_FUNCTION__ qLog(Warning) << "A location with ID" << id << "was already registered";
<< "A location with ID" << id << "was already registered";
return; return;
} }

View File

@ -17,6 +17,7 @@
#include "generator.h" #include "generator.h"
#include "querygenerator.h" #include "querygenerator.h"
#include "core/logging.h"
#include "radio/jamendodynamicplaylist.h" #include "radio/jamendodynamicplaylist.h"
#include <QSettings> #include <QSettings>
@ -39,7 +40,7 @@ GeneratorPtr Generator::Create(const QString& type) {
else if (type == "Jamendo") else if (type == "Jamendo")
return GeneratorPtr(new JamendoDynamicPlaylist); return GeneratorPtr(new JamendoDynamicPlaylist);
qWarning() << "Invalid playlist generator type:" << type; qLog(Warning) << "Invalid playlist generator type:" << type;
return GeneratorPtr(); return GeneratorPtr();
} }

View File

@ -90,7 +90,6 @@ QString Search::ToSql(const QString& songs_table) const {
sql += " LIMIT " + QString::number(limit_); sql += " LIMIT " + QString::number(limit_);
} }
qDebug() << sql;
return sql; return sql;
} }

View File

@ -17,6 +17,7 @@
#include "echonestbiographies.h" #include "echonestbiographies.h"
#include "songinfotextview.h" #include "songinfotextview.h"
#include "core/logging.h"
#include <echonest/Artist.h> #include <echonest/Artist.h>
@ -64,7 +65,7 @@ void EchoNestBiographies::RequestFinished() {
try { try {
request->artist_->parseProfile(reply); request->artist_->parseProfile(reply);
} catch (Echonest::ParseError e) { } catch (Echonest::ParseError e) {
qWarning() << "Error parsing echonest reply:" << e.errorType() << e.what(); qLog(Warning) << "Error parsing echonest reply:" << e.errorType() << e.what();
} }
QSet<QString> already_seen; QSet<QString> already_seen;

View File

@ -16,6 +16,7 @@
*/ */
#include "echonestimages.h" #include "echonestimages.h"
#include "core/logging.h"
#include <echonest/Artist.h> #include <echonest/Artist.h>
@ -48,7 +49,7 @@ void EchoNestImages::RequestFinished() {
try { try {
request->artist_->parseProfile(reply); request->artist_->parseProfile(reply);
} catch (Echonest::ParseError e) { } catch (Echonest::ParseError e) {
qWarning() << "Error parsing echonest reply:" << e.errorType() << e.what(); qLog(Warning) << "Error parsing echonest reply:" << e.errorType() << e.what();
} }
foreach (const Echonest::ArtistImage& image, request->artist_->images()) { foreach (const Echonest::ArtistImage& image, request->artist_->images()) {

View File

@ -17,6 +17,7 @@
#include "echonestsimilarartists.h" #include "echonestsimilarartists.h"
#include "tagwidget.h" #include "tagwidget.h"
#include "core/logging.h"
#include "ui/iconloader.h" #include "ui/iconloader.h"
#include <echonest/Artist.h> #include <echonest/Artist.h>
@ -47,7 +48,7 @@ void EchoNestSimilarArtists::RequestFinished() {
try { try {
artists = Echonest::Artist::parseSimilar(reply); artists = Echonest::Artist::parseSimilar(reply);
} catch (Echonest::ParseError e) { } catch (Echonest::ParseError e) {
qWarning() << "Error parsing echonest reply:" << e.errorType() << e.what(); qLog(Warning) << "Error parsing echonest reply:" << e.errorType() << e.what();
} }
if (!artists.isEmpty()) { if (!artists.isEmpty()) {

View File

@ -17,6 +17,7 @@
#include "echonesttags.h" #include "echonesttags.h"
#include "tagwidget.h" #include "tagwidget.h"
#include "core/logging.h"
#include <echonest/Artist.h> #include <echonest/Artist.h>
@ -49,7 +50,7 @@ void EchoNestTags::RequestFinished() {
try { try {
request->artist_->parseProfile(reply); request->artist_->parseProfile(reply);
} catch (Echonest::ParseError e) { } catch (Echonest::ParseError e) {
qWarning() << "Error parsing echonest reply:" << e.errorType() << e.what(); qLog(Warning) << "Error parsing echonest reply:" << e.errorType() << e.what();
} }
if (!request->artist_->terms().isEmpty()) { if (!request->artist_->terms().isEmpty()) {

View File

@ -17,6 +17,7 @@
#include "songinfofetcher.h" #include "songinfofetcher.h"
#include "songinfoprovider.h" #include "songinfoprovider.h"
#include "core/logging.h"
#include <QSignalMapper> #include <QSignalMapper>
#include <QTimer> #include <QTimer>
@ -98,7 +99,7 @@ void SongInfoFetcher::Timeout(int id) {
// Cancel any providers that we're still waiting for // Cancel any providers that we're still waiting for
foreach (SongInfoProvider* provider, waiting_for_[id]) { foreach (SongInfoProvider* provider, waiting_for_[id]) {
qDebug() << "Request timed out from info provider" << provider->name(); qLog(Info) << "Request timed out from info provider" << provider->name();
provider->Cancel(id); provider->Cancel(id);
} }
waiting_for_.remove(id); waiting_for_.remove(id);

View File

@ -17,6 +17,7 @@
#include "songinfotextview.h" #include "songinfotextview.h"
#include "ultimatelyricsprovider.h" #include "ultimatelyricsprovider.h"
#include "core/logging.h"
#include "core/network.h" #include "core/network.h"
#include <QNetworkReply> #include <QNetworkReply>
@ -38,7 +39,7 @@ void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) {
// Get the text codec // Get the text codec
const QTextCodec* codec = QTextCodec::codecForName(charset_.toAscii().constData()); const QTextCodec* codec = QTextCodec::codecForName(charset_.toAscii().constData());
if (!codec) { if (!codec) {
qWarning() << "Invalid codec" << charset_; qLog(Warning) << "Invalid codec" << charset_;
emit Finished(id); emit Finished(id);
return; return;
} }

View File

@ -17,6 +17,7 @@
#include "ultimatelyricsprovider.h" #include "ultimatelyricsprovider.h"
#include "ultimatelyricsreader.h" #include "ultimatelyricsreader.h"
#include "core/logging.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QFile> #include <QFile>
@ -30,7 +31,7 @@ UltimateLyricsReader::UltimateLyricsReader(QObject* parent)
QList<SongInfoProvider*> UltimateLyricsReader::Parse(const QString& filename) const { QList<SongInfoProvider*> UltimateLyricsReader::Parse(const QString& filename) const {
QFile file(filename); QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
qWarning() << "Error opening" << filename; qLog(Warning) << "Error opening" << filename;
return QList<SongInfoProvider*>(); return QList<SongInfoProvider*>();
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "transcoder.h" #include "transcoder.h"
#include "core/logging.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
@ -252,7 +253,7 @@ TranscoderPreset Transcoder::PresetForFileType(Song::FileType type) {
case Song::Type_Wav: case Song::Type_Wav:
return TranscoderPreset(type, "Wav", "wav", QString(), "audio/x-wav"); return TranscoderPreset(type, "Wav", "wav", QString(), "audio/x-wav");
default: default:
qWarning() << "Unsupported format in Transcoder::PresetForFileType:" << type; qLog(Warning) << "Unsupported format in PresetForFileType:" << type;
return TranscoderPreset(); return TranscoderPreset();
} }
} }
@ -337,7 +338,7 @@ void Transcoder::NewPadCallback(GstElement*, GstPad* pad, gboolean, gpointer dat
GstPad* const audiopad = gst_element_get_pad(state->convert_element_, "sink"); GstPad* const audiopad = gst_element_get_pad(state->convert_element_, "sink");
if (GST_PAD_IS_LINKED(audiopad)) { if (GST_PAD_IS_LINKED(audiopad)) {
qDebug() << "audiopad is already linked. Unlinking old pad."; qLog(Debug) << "audiopad is already linked, unlinking old pad";
gst_pad_unlink(audiopad, GST_PAD_PEER(audiopad)); gst_pad_unlink(audiopad, GST_PAD_PEER(audiopad));
} }

View File

@ -19,6 +19,7 @@
#include "edittagdialog.h" #include "edittagdialog.h"
#include "trackselectiondialog.h" #include "trackselectiondialog.h"
#include "ui_edittagdialog.h" #include "ui_edittagdialog.h"
#include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include "covers/albumcoverloader.h" #include "covers/albumcoverloader.h"
#include "library/library.h" #include "library/library.h"
@ -268,7 +269,7 @@ QVariant EditTagDialog::Data::value(const Song& song, const QString& id) {
if (id == "track") return song.track(); if (id == "track") return song.track();
if (id == "disc") return song.disc(); if (id == "disc") return song.disc();
if (id == "year") return song.year(); if (id == "year") return song.year();
qDebug() << "Unknown ID" << id; qLog(Warning) << "Unknown ID" << id;
return QVariant(); return QVariant();
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "iconloader.h" #include "iconloader.h"
#include "core/logging.h"
#include <QFile> #include <QFile>
#include <QtDebug> #include <QtDebug>
@ -50,6 +51,6 @@ QIcon IconLoader::Load(const QString &name) {
} }
if (ret.isNull()) if (ret.isNull())
qWarning() << "Couldn't load icon" << name; qLog(Warning) << "Couldn't load icon" << name;
return ret; return ret;
} }

View File

@ -22,6 +22,7 @@
#include "core/database.h" #include "core/database.h"
#include "core/deletefiles.h" #include "core/deletefiles.h"
#include "core/globalshortcuts.h" #include "core/globalshortcuts.h"
#include "core/logging.h"
#include "core/mac_startup.h" #include "core/mac_startup.h"
#include "core/mergedproxymodel.h" #include "core/mergedproxymodel.h"
#include "core/mimedata.h" #include "core/mimedata.h"
@ -1074,7 +1075,7 @@ void MainWindow::UpdateTrackPosition() {
if (playlist->get_lastfm_status() == Playlist::LastFM_New) { if (playlist->get_lastfm_status() == Playlist::LastFM_New) {
#ifdef HAVE_LIBLASTFM #ifdef HAVE_LIBLASTFM
if (lastfm_service->IsScrobblingEnabled()) { if (lastfm_service->IsScrobblingEnabled()) {
qDebug() << "Scrobbling at" << scrobble_point; qLog(Info) << "Scrobbling at" << scrobble_point;
lastfm_service->Scrobble(); lastfm_service->Scrobble();
} }
#endif #endif
@ -1094,7 +1095,7 @@ void MainWindow::UpdateTrackPosition() {
// Update the tray icon every 10 seconds // Update the tray icon every 10 seconds
if (position % 10 == 0) { if (position % 10 == 0) {
qDebug() << "position" << position << "scrobble point" << scrobble_point qLog(Debug) << "position" << position << "scrobble point" << scrobble_point
<< "status" << playlist->get_lastfm_status(); << "status" << playlist->get_lastfm_status();
tray_icon_->SetProgress(double(position) / length * 100); tray_icon_->SetProgress(double(position) / length * 100);
@ -2182,7 +2183,7 @@ void MainWindow::ScrobblerStatus(int value) {
if (value > 3) { if (value > 3) {
// we're for sure in an error state // we're for sure in an error state
playlists_->active()->set_lastfm_status(Playlist::LastFM_Error); playlists_->active()->set_lastfm_status(Playlist::LastFM_Error);
qWarning() << "Last.fm scrobbling error: " << value; qLog(Warning) << "Last.fm scrobbling error: " << value;
} }
break; break;
} }

View File

@ -16,6 +16,7 @@
*/ */
#include "windows7thumbbar.h" #include "windows7thumbbar.h"
#include "core/logging.h"
#include <QAction> #include <QAction>
#include <QtDebug> #include <QtDebug>
@ -91,7 +92,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG* msg) {
// Create the taskbar list for the first time // Create the taskbar list for the first time
if (CoCreateInstance(CLSID_ITaskbarList, NULL, CLSCTX_ALL, if (CoCreateInstance(CLSID_ITaskbarList, NULL, CLSCTX_ALL,
IID_ITaskbarList3, (void**) &taskbar_list_)) { IID_ITaskbarList3, (void**) &taskbar_list_)) {
qWarning() << "Error creating the ITaskbarList3 interface"; qLog(Warning) << "Error creating the ITaskbarList3 interface";
return; return;
} }

View File

@ -29,6 +29,7 @@
#include "fancytabwidget.h" #include "fancytabwidget.h"
#include "stylehelper.h" #include "stylehelper.h"
#include "core/logging.h"
#include <QDebug> #include <QDebug>
@ -589,7 +590,7 @@ void FancyTabWidget::SetMode(Mode mode) {
switch (mode) { switch (mode) {
case Mode_None: case Mode_None:
default: default:
qDebug() << "Unknown fancy tab mode" << mode; qLog(Warning) << "Unknown fancy tab mode" << mode;
// fallthrough // fallthrough
case Mode_LargeSidebar: { case Mode_LargeSidebar: {

View File

@ -1,36 +1,37 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Clementine is distributed in the hope that it will be useful, Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>. along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "osd.h" #include "osd.h"
#include "core/logging.h"
#include <QtDebug>
#include <QtDebug>
void OSD::Init() {
} void OSD::Init() {
}
bool OSD::SupportsNativeNotifications() {
return false; bool OSD::SupportsNativeNotifications() {
} return false;
}
bool OSD::SupportsTrayPopups() {
return true; bool OSD::SupportsTrayPopups() {
} return true;
}
void OSD::ShowMessageNative(const QString&, const QString&,
const QString&, const QImage&) { void OSD::ShowMessageNative(const QString&, const QString&,
qWarning() << __PRETTY_FUNCTION__ << ": NOT IMPLEMENTED"; const QString&, const QImage&) {
} qLog(Warning) << "not implemented";
}

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include "osd.h" #include "osd.h"
#include "core/logging.h"
#include <QtDebug> #include <QtDebug>
@ -66,7 +67,7 @@ void OSD::Init() {
"/org/freedesktop/Notifications", "/org/freedesktop/Notifications",
QDBusConnection::sessionBus())); QDBusConnection::sessionBus()));
if (!interface_->isValid()) { if (!interface_->isValid()) {
qWarning() << "Error connecting to notifications service."; qLog(Warning) << "Error connecting to notifications service.";
} }
#endif // HAVE_DBUS #endif // HAVE_DBUS
} }
@ -116,7 +117,7 @@ void OSD::ShowMessageNative(const QString& summary, const QString& message,
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
SLOT(CallFinished(QDBusPendingCallWatcher*))); SLOT(CallFinished(QDBusPendingCallWatcher*)));
#else // HAVE_DBUS #else // HAVE_DBUS
qWarning() << __PRETTY_FUNCTION__ << ": NOT IMPLEMENTED"; qLog(Warning) << "not implemented";
#endif // HAVE_DBUS #endif // HAVE_DBUS
} }
@ -126,7 +127,7 @@ void OSD::CallFinished(QDBusPendingCallWatcher* watcher) {
QDBusPendingReply<uint> reply = *watcher; QDBusPendingReply<uint> reply = *watcher;
if (reply.isError()) { if (reply.isError()) {
qWarning() << "Error sending notification" << reply.error().name(); qLog(Warning) << "Error sending notification" << reply.error().name();
return; return;
} }