Skip to content

Commit

Permalink
tagreader: Add debug handler for taglib
Browse files Browse the repository at this point in the history
Pass taglib debug messages through qLog instead of printing directly to stderr.
  • Loading branch information
jbroadus authored and hatstand committed Apr 19, 2020
1 parent 934fd33 commit 509c65c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ext/libclementine-tagreader/tagreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 509c65c

Please sign in to comment.