1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-23 00:09:14 +01:00

tagreader: Add debug handler for taglib

Pass taglib debug messages through qLog instead of printing directly to stderr.
This commit is contained in:
Jim Broadus 2020-04-18 15:23:51 -07:00 committed by John Maguire
parent 934fd336da
commit 509c65ced7

View File

@ -47,6 +47,7 @@
#include <popularimeterframe.h>
#include <speexfile.h>
#include <tag.h>
#include <tdebuglistener.h>
#include <textidentificationframe.h>
#include <trueaudiofile.h>
#include <tstring.h>
@ -87,6 +88,22 @@ class TagLibFileRefFactory : public FileRefFactory {
}
};
// Handler to push TagLib messages to qLog instead of printing to stderr.
class TagReaderDebugListener : public TagLib::DebugListener {
private:
TagReaderDebugListener() {
// Install handler.
TagLib::setDebugListener(this);
}
virtual void printMessage(const TagLib::String &msg) override {
// Remove trailing newline.
qLog(Debug).noquote() << TStringToQString(msg).trimmed();
}
static TagReaderDebugListener listener_;
};
TagReaderDebugListener TagReaderDebugListener::listener_;
namespace {
TagLib::String StdStringToTaglibString(const std::string& s) {