feat: tracing

This commit is contained in:
Nova
2022-12-02 20:46:28 -05:00
parent d7a607a663
commit c171d9e6db
9 changed files with 82 additions and 49 deletions

View File

@@ -19,12 +19,13 @@ use smithay::{
backend::{egl::EGLContext, renderer::gles2::Gles2Renderer},
reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket, Resource},
};
use tracing::info;
use std::{
ffi::c_void,
os::unix::{net::UnixListener, prelude::FromRawFd},
sync::Arc,
};
use std::{os::unix::prelude::AsRawFd, time::Duration};
use std::{os::unix::prelude::AsRawFd};
use stereokit as sk;
use stereokit::StereoKit;
use tokio::{
@@ -64,8 +65,7 @@ pub struct Wayland {
}
impl Wayland {
pub fn new() -> Result<Self> {
let log = ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), slog::o!());
slog_stdlog::init()?;
let log = ::slog::Logger::root(::tracing_slog::TracingSlogDrain.fuse(), slog::o!());
let egl_raw_handles = get_sk_egl()?;
let renderer = unsafe {
@@ -108,7 +108,7 @@ impl Wayland {
) -> Result<JoinHandle<Result<()>>> {
let socket = ListeningSocket::bind_auto("wayland", 0..33)?;
if let Some(socket_name) = socket.socket_name() {
println!("Wayland compositor {:?} active", socket_name);
info!("Wayland compositor {:?} active", socket_name);
}
let listen_async =
@@ -146,8 +146,6 @@ impl Wayland {
}
pub fn frame(&mut self, sk: &StereoKit) {
let time_ms = (sk.time_getf() * 1000.) as u64;
for core_surface in CORE_SURFACES.get_valid_contents() {
let Some(client_id) =
core_surface
@@ -161,7 +159,6 @@ impl Wayland {
sk,
&mut self.renderer,
output,
Duration::from_millis(time_ms),
&self.log,
|data| {
PanelItem::on_mapped(&core_surface, data, seat_data);

View File

@@ -27,15 +27,16 @@ use smithay::{
},
};
use std::sync::{Arc, Weak};
use tracing::info;
pub struct ClientState;
impl ClientData for ClientState {
fn initialized(&self, client_id: ClientId) {
println!("Wayland client {:?} connected", client_id);
info!("Wayland client {:?} connected", client_id);
}
fn disconnected(&self, client_id: ClientId, reason: DisconnectReason) {
println!(
info!(
"Wayland client {:?} disconnected because {:#?}",
client_id, reason
);
@@ -98,7 +99,7 @@ impl WaylandState {
);
display_handle.create_global::<Self, WlDataDeviceManager, _>(3, ());
println!("Init Wayland compositor");
info!("Init Wayland compositor");
Arc::new_cyclic(|weak| {
Mutex::new(WaylandState {
@@ -127,7 +128,7 @@ impl WaylandState {
}
impl Drop for WaylandState {
fn drop(&mut self) {
println!("Cleanly shut down the Wayland compositor");
info!("Cleanly shut down the Wayland compositor");
}
}
impl BufferHandler for WaylandState {

View File

@@ -135,7 +135,6 @@ impl CoreSurface {
sk: &StereoKit,
renderer: &mut Gles2Renderer,
output: Output,
time: Duration,
log: &Logger,
on_mapped: F,
if_mapped: M,
@@ -182,9 +181,13 @@ impl CoreSurface {
if_mapped(data);
});
send_frames_surface_tree(&wl_surface, &output, time, None, |_, _| {
Some(output.clone())
});
send_frames_surface_tree(
&wl_surface,
&output,
Duration::from_secs_f64(sk.time_get()),
None,
|_, _| Some(output.clone()),
);
}
pub fn set_material_offset(&self, material_offset: u32) {