1
0
Fork 0

Improve logging, fix #21

This commit is contained in:
namedkitten 2020-05-11 11:46:40 +01:00
parent bf3989b7e6
commit a0cb65ceeb
4 changed files with 27 additions and 13 deletions

View file

@ -521,14 +521,18 @@ void handle_mpv_event(BackendInterface* b, mpv_event* event)
case MPV_EVENT_LOG_MESSAGE: {
struct mpv_event_log_message* msg = (struct mpv_event_log_message*)event->data;
QString logMsg = "[" + QString(msg->prefix) + "] " + QString(msg->text);
QString logMsg = "[" + QString(msg->prefix) + "] " + QString(msg->text).trimmed();
QString msgLevel = QString(msg->level);
if (msgLevel.startsWith("d") || msgLevel.startsWith("t")) {
if (msgLevel.startsWith("d")) {
mpvLogger->info("{}", logMsg.toStdString());
} else if (msgLevel.startsWith("v") || msgLevel.startsWith("i")) {
} else if (msgLevel.startsWith("t")) {
mpvLogger->warn("{}", logMsg.toStdString());
} else if (msgLevel.startsWith("v")) {
mpvLogger->trace("{}", logMsg.toStdString());
} else if (msgLevel.startsWith("i")) {
mpvLogger->info("{}", logMsg.toStdString());
} else {
mpvLogger->debug("{}", logMsg.toStdString());
mpvLogger->warn("What: {}", logMsg.toStdString());
}
break;

View file

@ -36,7 +36,7 @@ initLogger(std::string name)
auto console = std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks));
console->set_pattern("[%l][%n] %v%$");
spdlog::register_logger(console);
console->set_level(spdlog::level::debug);
console->set_level(spdlog::level::info);
return spdlog::get(name);

View file

@ -33,7 +33,7 @@ Dialog {
}
Timer {
interval: 100
interval: 500
repeat: true
triggeredOnStart: true
running: true
@ -49,7 +49,7 @@ Dialog {
var thumbnailerProcess = component.createObject(playlistDialog, {
"name": thumbnailJobs[0]
})
if (String(titleJobs[0]).indexOf("://") !== -1) {
if (String(thumbnailJobs[0]).indexOf("://") !== -1) {
thumbnailerProcess.start("youtube-dl",
["--get-thumbnail", thumbnailJobs[0]])
@ -74,8 +74,7 @@ Dialog {
onTriggered: {
if (titleJobsRunning < 5) {
if (titleJobs.length > 0) {
if (titleJobs[0].startsWith(
"https://www.youtube.com/playlist?list=")) {
if (titleJobs[0].startsWith("https://www.youtube.com/playlist?list=")) {
titleJobs.shift()
return
}
@ -132,6 +131,7 @@ Dialog {
Connections {
target: thumbnailCache
onThumbnailReady: function (name, url, path) {
console.error(name,url,path,playlistItem.itemURL)
if (name == playlistItem.itemURL) {
thumbnail.source = path
}
@ -183,7 +183,6 @@ Dialog {
}
Component.onCompleted: {
if (typeof playlistItemTitle !== "undefined") {
playlistItem.itemTitle = playlistItemTitle
} else {
@ -215,4 +214,7 @@ Dialog {
}
focus: true
}
Component.onCompleted: {
playlistDialog.open()
}
}

View file

@ -101,8 +101,16 @@ MenuBar {
}
}
PlaylistDialog {
id: playlistDialog
Loader {
id: playlistDialogLoader
active: false
source: "PlaylistDialog.qml"
}
Connections {
target: playlistDialogLoader.item
onDone: {
playlistDialogLoader.active = false
}
}
Loader {
@ -467,7 +475,7 @@ MenuBar {
Action {
text: translate.getTranslation("PLAYLIST_MENU", i18n.language)
onTriggered: {
playlistDialog.open()
playlistDialogLoader.active = true
}
}
Action {