Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Log] Use Qt's category logging capabilities #1278

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
1000 movie directories, the time improvements were:
- 3.8s -> 1.3s (SSD)
- 4.1s -> 1.4s (HDD)
- Fix unuseful log warning "[KodiXml] NFO file could not be opened for reading" for TV shows that do not have a NFO file.

- Fix unuseful log warning `[KodiXml] NFO file could not be opened for reading` for TV shows that do not have a NFO file.
- MediaElch now uses Qt's logging categories

## 2.8.6 - Coridian (2021-01-22)

Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ mediaelch_post_target_defaults(mediaelch)
install(TARGETS mediaelch RUNTIME DESTINATION bin RENAME MediaElch)
install(FILES data/desktop/MediaElch.desktop DESTINATION share/applications)
install(FILES data/desktop/MediaElch.png DESTINATION share/pixmaps)
install(FILES data/desktop/com.kvibes.MediaElch.metainfo.xml DESTINATION share/metainfo)
install(
FILES data/desktop/com.kvibes.MediaElch.metainfo.xml
DESTINATION share/metainfo
)

# ------------------------------------------------------------------------------
# Testing
Expand Down
1 change: 1 addition & 0 deletions cmake/warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function(enable_warnings warning_target)
-Wdocumentation # Warns about doxygen variable
# name mismatches, etc.
>
-Wno-gnu-zero-variadic-macro-arguments # false positive for qCDebug
$<$<CXX_COMPILER_ID:MSVC>:
/W3>
)
Expand Down
9 changes: 4 additions & 5 deletions src/concerts/Concert.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#include "Concert.h"

#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QFileInfo>

#include "data/StreamDetails.h"
#include "file/NameFormatter.h"
#include "globals/Helper.h"
#include "media_centers/MediaCenterInterface.h"
#include "settings/Settings.h"

#include <QApplication>
#include <QDir>
#include <QFileInfo>

using namespace std::chrono_literals;

/**
Expand Down
14 changes: 7 additions & 7 deletions src/concerts/ConcertFileSearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "globals/Helper.h"
#include "globals/Manager.h"
#include "globals/MessageIds.h"
#include "log/Log.h"

#include <QApplication>
#include <QDebug>
#include <QRegularExpression>
#include <QSqlQuery>
#include <QSqlRecord>
Expand All @@ -21,18 +21,18 @@ void ConcertFileSearcher::setConcertDirectories(QVector<SettingsDir> directories

for (const auto& dir : directories) {
if (Settings::instance()->advanced()->isFolderExcluded(dir.path.dirName())) {
qWarning() << "[ConcertFileSearcher] Concert directory is excluded by advanced settings! "
"Is this intended? Directory:"
<< dir.path.path();
qCWarning(generic) << "[ConcertFileSearcher] Concert directory is excluded by advanced settings! "
"Is this intended? Directory:"
<< dir.path.path();
continue;
}

if (!dir.path.isReadable()) {
qDebug() << "[ConcertFileSearcher] Concert directory is not redable, skipping:" << dir.path.path();
qCDebug(generic) << "[ConcertFileSearcher] Concert directory is not redable, skipping:" << dir.path.path();
continue;
}

qDebug() << "[ConcertFileSearcher] Adding concert directory" << dir.path.path();
qCDebug(generic) << "[ConcertFileSearcher] Adding concert directory" << dir.path.path();
m_directories.append(dir);
}
}
Expand All @@ -58,7 +58,7 @@ void ConcertFileSearcher::reload(bool force)

addConcertsToGui(loadConcertsFromDatabase());

qDebug() << "Searching for concerts done";
qCDebug(generic) << "Searching for concerts done";
if (!m_aborted) {
emit concertsLoaded();
}
Expand Down
3 changes: 1 addition & 2 deletions src/concerts/ConcertProxyModel.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "ConcertProxyModel.h"

#include <QDebug>

#include "globals/Filter.h"
#include "globals/Globals.h"
#include "globals/Manager.h"
#include "log/Log.h"

/**
* \brief ConcertProxyModel::ConcertProxyModel
Expand Down
6 changes: 3 additions & 3 deletions src/data/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "globals/Helper.h"
#include "globals/Manager.h"
#include "globals/Meta.h"
#include "log/Log.h"
#include "media_centers/KodiXml.h"
#include "media_centers/kodi/EpisodeXmlWriter.h"
#include "movies/Movie.h"
Expand All @@ -13,7 +14,6 @@
#include "settings/Settings.h"
#include "tv_shows/TvShow.h"

#include <QDebug>
#include <QDesktopServices>
#include <QDir>
#include <QSqlError>
Expand All @@ -32,7 +32,7 @@ Database::Database(QObject* parent) : QObject(parent)
m_db = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE", "mediaDb"));
m_db->setDatabaseName(dataLocation.filePath("MediaElch.sqlite"));
if (!m_db->open()) {
qWarning() << "Could not open cache database";
qCWarning(generic) << "Could not open cache database";
} else {
QSqlQuery query(*m_db);

Expand Down Expand Up @@ -420,7 +420,7 @@ QVector<Movie*> Database::moviesInDirectory(DirectoryPath path)
movie = movies.value(query.value(query.record().indexOf("idMovie")).toInt());
if (movie == nullptr) {
// This *must* not happen because we just inserted it.
qCritical() << "[Database] Movie is undefined but should exist!";
qCCritical(generic) << "[Database] Movie is undefined but should exist!";
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/data/ImageCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <QCryptographicHash>
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QFileInfo>

#include "globals/Globals.h"
#include "globals/Helper.h"
#include "log/Log.h"
#include "settings/Settings.h"

ImageCache::ImageCache(QObject* parent) : QObject(parent)
Expand All @@ -26,7 +26,7 @@ ImageCache::ImageCache(QObject* parent) : QObject(parent)
if (exists) {
m_cacheDir = location;
}
qDebug() << "[ImageCache] Using cache dir:" << m_cacheDir;
qCDebug(generic) << "[ImageCache] Using cache dir:" << m_cacheDir;

m_forceCache = Settings::instance()->advanced()->forceCache();
}
Expand Down
6 changes: 3 additions & 3 deletions src/data/Locale.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "data/Locale.h"

#include <QDebug>
#include "log/Log.h"

namespace mediaelch {

Expand All @@ -19,7 +19,7 @@ Locale::Locale(const QString& locale)
m_country = split[1];
}
if (split.size() > 2) {
qWarning() << "[Locale] Invalid locale format:" << locale;
qCWarning(generic) << "[Locale] Invalid locale format:" << locale;
}
}

Expand Down Expand Up @@ -134,7 +134,7 @@ QString Locale::languageTranslated() const
}
return localeTextMap[m_lang];
}
qDebug() << "[Locale] Missing name for" << locale;
qCDebug(generic) << "[Locale] Missing name for" << locale;
return locale;
}

Expand Down
14 changes: 7 additions & 7 deletions src/data/MediaInfoFile.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "data/MediaInfoFile.h"

#include "globals/Helper.h"
#include "log/Log.h"
#include "settings/Settings.h"

#include "MediaInfoDLL/MediaInfoDLL.h"

#include <ZenLib/Ztring.h>
#include <ZenLib/ZtringListList.h>

#include <QDebug>
#include <QRegularExpression>
#include <QStringList>

Expand All @@ -28,7 +28,7 @@ MediaInfoFile::MediaInfoFile(const QString& filepath) : m_mediaInfo{std::make_un
m_mediaInfo->Option(__T("Complete"), __T("1"));
m_mediaInfo->Open(QString2MI(filepath));
if (!m_mediaInfo->IsReady()) {
qCritical() << "[MediaInfo] Unable to load libmediainfo!";
qCCritical(generic) << "[MediaInfo] Unable to load libmediainfo!";
}
}

Expand Down Expand Up @@ -320,7 +320,7 @@ QString MediaInfoFile::parseVideoFormat(QString format, QString version) const
QString MediaInfoFile::getGeneral(int streamIndex, const char* parameter) const
{
if (streamIndex < 0) {
qWarning() << "[MediaInfoFile][General] Negative streamIndex! Invalid value:" << streamIndex;
qCWarning(generic) << "[MediaInfoFile][General] Negative streamIndex! Invalid value:" << streamIndex;
return {};
}
return MI2QString(
Expand All @@ -330,7 +330,7 @@ QString MediaInfoFile::getGeneral(int streamIndex, const char* parameter) const
QString MediaInfoFile::getAudio(int streamIndex, const char* parameter) const
{
if (streamIndex < 0) {
qWarning() << "[MediaInfoFile][Audio] Negative streamIndex! Invalid value:" << streamIndex;
qCWarning(generic) << "[MediaInfoFile][Audio] Negative streamIndex! Invalid value:" << streamIndex;
return {};
}
return MI2QString(
Expand All @@ -340,7 +340,7 @@ QString MediaInfoFile::getAudio(int streamIndex, const char* parameter) const
QStringList MediaInfoFile::getAudio(int streamIndex, QStringList parameters) const
{
if (streamIndex < 0) {
qWarning() << "[MediaInfoFile][Video] Negative streamIndex! Invalid value:" << streamIndex;
qCWarning(generic) << "[MediaInfoFile][Video] Negative streamIndex! Invalid value:" << streamIndex;
return {};
}

Expand All @@ -357,7 +357,7 @@ QStringList MediaInfoFile::getAudio(int streamIndex, QStringList parameters) con
QString MediaInfoFile::getVideo(int streamIndex, const char* parameter) const
{
if (streamIndex < 0) {
qWarning() << "[MediaInfoFile][Video] Negative streamIndex! Invalid value:" << streamIndex;
qCWarning(generic) << "[MediaInfoFile][Video] Negative streamIndex! Invalid value:" << streamIndex;
return {};
}
return MI2QString(
Expand All @@ -367,7 +367,7 @@ QString MediaInfoFile::getVideo(int streamIndex, const char* parameter) const
QString MediaInfoFile::getText(int streamIndex, const char* parameter) const
{
if (streamIndex < 0) {
qWarning() << "[MediaInfoFile][Text] Negative streamIndex! Invalid value:" << streamIndex;
qCWarning(generic) << "[MediaInfoFile][Text] Negative streamIndex! Invalid value:" << streamIndex;
return {};
}
return MI2QString(
Expand Down
12 changes: 6 additions & 6 deletions src/data/StreamDetails.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "StreamDetails.h"

#include "data/MediaInfoFile.h"
#include "log/Log.h"

#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QProcess>
#include <QRegularExpression>

#include "data/MediaInfoFile.h"

StreamDetails::StreamDetails(QObject* parent, mediaelch::FileList files) :
QObject(parent),
m_files(std::move(files)),
Expand All @@ -29,7 +29,7 @@ QString StreamDetails::detailToString(VideoDetails details)
case VideoDetails::ScanType: return "scantype";
case VideoDetails::StereoMode: return "stereomode";
}
qWarning() << "Undefined video detail: no string representation";
qCWarning(generic) << "Undefined video detail: no string representation";
return "undefined";
}

Expand All @@ -40,7 +40,7 @@ QString StreamDetails::detailToString(AudioDetails details)
case StreamDetails::AudioDetails::Language: return "language";
case StreamDetails::AudioDetails::Channels: return "channels";
}
qWarning() << "Undefined audio detail: no string representation";
qCWarning(generic) << "Undefined audio detail: no string representation";
return "undefined";
}

Expand All @@ -49,7 +49,7 @@ QString StreamDetails::detailToString(SubtitleDetails details)
switch (details) {
case StreamDetails::SubtitleDetails::Language: return "language";
}
qWarning() << "Undefined subtitle detail: no string representation";
qCWarning(generic) << "Undefined subtitle detail: no string representation";
return "undefined";
}

Expand Down
2 changes: 1 addition & 1 deletion src/export/ExportTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ bool ExportTemplate::copyDir(const QString& srcPath, const QString& dstPath)
return false;
}
} else {
qDebug() << "Unhandled item" << info.filePath() << "in cpDir";
qCDebug(generic) << "Unhandled item" << info.filePath() << "in cpDir";
}
}
return true;
Expand Down