mpv logge
This commit is contained in:
parent
daff4e7dbd
commit
2c1eb852fd
2 changed files with 37 additions and 14 deletions
|
@ -55,9 +55,14 @@ impl Handle {
|
|||
);
|
||||
}
|
||||
|
||||
// set up info logging for now
|
||||
// wraps via tracing later; note that info does nothing for now as it disables all logs
|
||||
#[cfg(debug_assertions)]
|
||||
let loglevel = c"trace";
|
||||
#[cfg(not(debug_assertions))]
|
||||
let loglevel = c"info";
|
||||
|
||||
Error::from_return_code(unsafe {
|
||||
ffi::mpv_request_log_messages(inner.as_ptr(), c"info".as_ptr())
|
||||
ffi::mpv_request_log_messages(inner.as_ptr(), loglevel.as_ptr())
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ mod imp {
|
|||
use gtk::{gdk, gio, glib};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use tracing::{event, Level};
|
||||
use tracing::{event, span, Level};
|
||||
|
||||
#[derive(gtk::CompositeTemplate, glib::Properties)]
|
||||
#[template(resource = "/eu/callcc/audrey/window.ui")]
|
||||
|
@ -117,6 +117,9 @@ mod imp {
|
|||
while let Some(event) = window.imp().mpv.wait_event(0.0) {
|
||||
use crate::mpv::Event;
|
||||
|
||||
let span = span!(Level::DEBUG, "mpv_wait_event");
|
||||
let _guard = span.enter();
|
||||
|
||||
match event {
|
||||
Event::PropertyChange(event) => match event.reply_userdata {
|
||||
0 => {
|
||||
|
@ -164,17 +167,32 @@ mod imp {
|
|||
},
|
||||
|
||||
Event::LogMessage(event) => {
|
||||
// TODO: levels etc
|
||||
if event.log_level < 30 {
|
||||
event!(target: "mpv", Level::ERROR, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else if event.log_level < 40 {
|
||||
event!(target: "mpv", Level::WARN, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else if event.log_level < 50 {
|
||||
event!(target: "mpv", Level::INFO, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else if event.log_level < 70 {
|
||||
event!(target: "mpv", Level::DEBUG, "[{}] {}", event.prefix, event.text.trim());
|
||||
} else {
|
||||
event!(target: "mpv", Level::TRACE, "[{}] {}", event.prefix, event.text.trim());
|
||||
match event.log_level {
|
||||
// level has to be 'static so this sux
|
||||
l if l <= 20 => {
|
||||
event!(target: "mpv", Level::ERROR, prefix = event.prefix, event = event.text.trim())
|
||||
}
|
||||
l if l <= 30 => {
|
||||
event!(target: "mpv", Level::WARN, prefix = event.prefix, event = event.text.trim())
|
||||
}
|
||||
l if l <= 40 => {
|
||||
event!(target: "mpv", Level::INFO, prefix = event.prefix, event = event.text.trim())
|
||||
}
|
||||
l if l <= 60 => {
|
||||
event!(target: "mpv", Level::DEBUG, prefix = event.prefix, event = event.text.trim())
|
||||
}
|
||||
l if l <= 70 => {
|
||||
event!(target: "mpv", Level::TRACE, prefix = event.prefix, event = event.text.trim())
|
||||
}
|
||||
// should be unused
|
||||
_ => event!(
|
||||
target: "mpv",
|
||||
Level::DEBUG,
|
||||
prefix = event.prefix,
|
||||
event = event.text.trim(),
|
||||
"unknown mpv level: {}",
|
||||
event.log_level,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue