Improve logging, fix #21
This commit is contained in:
parent
bf3989b7e6
commit
a0cb65ceeb
|
@ -521,14 +521,18 @@ void handle_mpv_event(BackendInterface* b, mpv_event* event)
|
||||||
|
|
||||||
case MPV_EVENT_LOG_MESSAGE: {
|
case MPV_EVENT_LOG_MESSAGE: {
|
||||||
struct mpv_event_log_message* msg = (struct mpv_event_log_message*)event->data;
|
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);
|
QString msgLevel = QString(msg->level);
|
||||||
if (msgLevel.startsWith("d") || msgLevel.startsWith("t")) {
|
if (msgLevel.startsWith("d")) {
|
||||||
mpvLogger->info("{}", logMsg.toStdString());
|
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());
|
mpvLogger->info("{}", logMsg.toStdString());
|
||||||
} else {
|
} else {
|
||||||
mpvLogger->debug("{}", logMsg.toStdString());
|
mpvLogger->warn("What: {}", logMsg.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,7 @@ initLogger(std::string name)
|
||||||
auto console = std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks));
|
auto console = std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks));
|
||||||
console->set_pattern("[%l][%n] %v%$");
|
console->set_pattern("[%l][%n] %v%$");
|
||||||
spdlog::register_logger(console);
|
spdlog::register_logger(console);
|
||||||
console->set_level(spdlog::level::debug);
|
console->set_level(spdlog::level::info);
|
||||||
|
|
||||||
|
|
||||||
return spdlog::get(name);
|
return spdlog::get(name);
|
||||||
|
|
|
@ -33,7 +33,7 @@ Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 100
|
interval: 500
|
||||||
repeat: true
|
repeat: true
|
||||||
triggeredOnStart: true
|
triggeredOnStart: true
|
||||||
running: true
|
running: true
|
||||||
|
@ -49,7 +49,7 @@ Dialog {
|
||||||
var thumbnailerProcess = component.createObject(playlistDialog, {
|
var thumbnailerProcess = component.createObject(playlistDialog, {
|
||||||
"name": thumbnailJobs[0]
|
"name": thumbnailJobs[0]
|
||||||
})
|
})
|
||||||
if (String(titleJobs[0]).indexOf("://") !== -1) {
|
if (String(thumbnailJobs[0]).indexOf("://") !== -1) {
|
||||||
|
|
||||||
thumbnailerProcess.start("youtube-dl",
|
thumbnailerProcess.start("youtube-dl",
|
||||||
["--get-thumbnail", thumbnailJobs[0]])
|
["--get-thumbnail", thumbnailJobs[0]])
|
||||||
|
@ -74,8 +74,7 @@ Dialog {
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (titleJobsRunning < 5) {
|
if (titleJobsRunning < 5) {
|
||||||
if (titleJobs.length > 0) {
|
if (titleJobs.length > 0) {
|
||||||
if (titleJobs[0].startsWith(
|
if (titleJobs[0].startsWith("https://www.youtube.com/playlist?list=")) {
|
||||||
"https://www.youtube.com/playlist?list=")) {
|
|
||||||
titleJobs.shift()
|
titleJobs.shift()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -132,6 +131,7 @@ Dialog {
|
||||||
Connections {
|
Connections {
|
||||||
target: thumbnailCache
|
target: thumbnailCache
|
||||||
onThumbnailReady: function (name, url, path) {
|
onThumbnailReady: function (name, url, path) {
|
||||||
|
console.error(name,url,path,playlistItem.itemURL)
|
||||||
if (name == playlistItem.itemURL) {
|
if (name == playlistItem.itemURL) {
|
||||||
thumbnail.source = path
|
thumbnail.source = path
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,6 @@ Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|
||||||
if (typeof playlistItemTitle !== "undefined") {
|
if (typeof playlistItemTitle !== "undefined") {
|
||||||
playlistItem.itemTitle = playlistItemTitle
|
playlistItem.itemTitle = playlistItemTitle
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,4 +214,7 @@ Dialog {
|
||||||
}
|
}
|
||||||
focus: true
|
focus: true
|
||||||
}
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
playlistDialog.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,16 @@ MenuBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistDialog {
|
Loader {
|
||||||
id: playlistDialog
|
id: playlistDialogLoader
|
||||||
|
active: false
|
||||||
|
source: "PlaylistDialog.qml"
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: playlistDialogLoader.item
|
||||||
|
onDone: {
|
||||||
|
playlistDialogLoader.active = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
@ -467,7 +475,7 @@ MenuBar {
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("PLAYLIST_MENU", i18n.language)
|
text: translate.getTranslation("PLAYLIST_MENU", i18n.language)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
playlistDialog.open()
|
playlistDialogLoader.active = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
|
|
Loading…
Reference in a new issue