Hook up GST_DEBUG log to visual studio output

This commit is contained in:
Fernando Jiménez Moreno 2019-09-23 12:20:02 +02:00
parent 4fe8238b14
commit 558dd8b32d
3 changed files with 49 additions and 16 deletions

View file

@ -86,8 +86,9 @@ webxr-api = {git = "https://github.com/servo/webxr"}
[target.'cfg(all(not(target_os = "windows"), not(target_os = "ios"), not(target_os="android"), not(target_arch="arm"), not(target_arch="aarch64")))'.dependencies]
gaol = {git = "https://github.com/servo/gaol"}
[target.'cfg(any(target_os = "android", target_arch = "x86_64", target_os = "windows"))'.dependencies.servo-media-gstreamer]
git = "https://github.com/servo/media"
[target.'cfg(any(target_os = "android", target_arch = "x86_64", target_os = "windows"))'.dependencies]
gstreamer = "0.14.5"
servo-media-gstreamer= {git = "https://github.com/servo/media"}
[target.'cfg(not(any(target_os = "android", target_arch = "x86_64", target_os = "windows")))'.dependencies.servo-media-dummy]
git = "https://github.com/servo/media"

View file

@ -130,6 +130,34 @@ mod media_platform {
use super::ServoMedia;
use servo_media_gstreamer::GStreamerBackend;
#[cfg(target_os = "windows")]
fn set_gstreamer_log_handler() {
use gstreamer::{debug_add_log_function, debug_remove_default_log_function, DebugLevel};
debug_remove_default_log_function();
debug_add_log_function(|cat, level, file, function, line, _, message| {
let message = format!(
"{:?} {:?} {:?}:{:?}:{:?} {:?}",
cat.get_name(),
level,
file,
line,
function,
message
);
match level {
DebugLevel::Debug => debug!("{}", message),
DebugLevel::Error => error!("{}", message),
DebugLevel::Warning => warn!("{}", message),
DebugLevel::Fixme | DebugLevel::Info => info!("{}", message),
DebugLevel::Memdump | DebugLevel::Count | DebugLevel::Trace => {
trace!("{}", message)
},
_ => (),
}
});
}
#[cfg(windows)]
pub fn init() {
// UWP apps have the working directory set appropriately. Win32 apps
@ -195,6 +223,9 @@ mod media_platform {
},
};
ServoMedia::init_with_backend(backend);
if cfg!(feature = "uwp") {
set_gstreamer_log_handler();
}
}
#[cfg(not(windows))]