debug logging idk
This commit is contained in:
parent
fc32b0dc2b
commit
b754cb1e11
13 changed files with 116 additions and 19 deletions
69
Cargo.lock
generated
69
Cargo.lock
generated
|
@ -232,6 +232,8 @@ dependencies = [
|
|||
"reqwest",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"url",
|
||||
"zbus 5.0.1",
|
||||
]
|
||||
|
@ -1450,6 +1452,16 @@ dependencies = [
|
|||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.4.3"
|
||||
|
@ -1628,6 +1640,12 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.20.4"
|
||||
|
@ -2109,6 +2127,15 @@ dependencies = [
|
|||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
|
@ -2245,6 +2272,16 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.8.0"
|
||||
|
@ -2368,6 +2405,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
||||
dependencies = [
|
||||
"nu-ansi-term",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2431,6 +2494,12 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.0"
|
||||
|
|
|
@ -22,6 +22,8 @@ reqwest = { version = "0.12.9", default-features = false, features = [
|
|||
] }
|
||||
serde = { version = "1.0.214", features = ["derive"] }
|
||||
tokio = { version = "1", features = ["rt-multi-thread"] }
|
||||
tracing = { version = "0.1.40", default-features = false, features = ["attributes", "std"] }
|
||||
tracing-subscriber = "0.3.18"
|
||||
url = "2.5.2"
|
||||
zbus = { version = "5.0.1", features = ["chrono"] }
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ mod imp {
|
|||
use crate::ui;
|
||||
use adw::{prelude::*, subclass::prelude::*};
|
||||
use gtk::glib;
|
||||
use tracing::{event, Level};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Application {}
|
||||
|
@ -36,7 +37,7 @@ mod imp {
|
|||
|
||||
impl Drop for Application {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyApplication");
|
||||
event!(Level::DEBUG, "dropping AudreyApplication");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -28,9 +28,19 @@ use gtk::{gio, glib};
|
|||
|
||||
pub mod mpv;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn init_tracing() {
|
||||
tracing_subscriber::fmt::init();
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn init_tracing() {}
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
gio::resources_register_include!("audrey.gresource").expect("could not register resources");
|
||||
|
||||
init_tracing();
|
||||
|
||||
ui::Playbar::ensure_type();
|
||||
ui::PlayQueue::ensure_type();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ pub use player::Player;
|
|||
|
||||
use adw::prelude::*;
|
||||
use gtk::glib;
|
||||
use tracing::{event, Level};
|
||||
|
||||
pub struct Mpris {
|
||||
window: glib::SendWeakRef<crate::ui::Window>,
|
||||
|
@ -96,6 +97,6 @@ impl Mpris {
|
|||
|
||||
impl Drop for Mpris {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping Mpris");
|
||||
event!(Level::DEBUG, "dropping Mpris");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::{Playbin, PlaybinSong};
|
|||
use gtk::glib::spawn_future_local;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::{Rc, Weak};
|
||||
use tracing::{event, Level};
|
||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value};
|
||||
|
||||
const MICROSECONDS: f64 = 1e6; // in a second
|
||||
|
@ -576,6 +577,6 @@ impl LocalPlayer {
|
|||
|
||||
impl Drop for Player {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping MprisPlayer");
|
||||
event!(Level::DEBUG, "dropping MprisPlayer");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use super::{event, ffi, Error, Event as MpvEvent, GetProperty, SetProperty};
|
||||
use event::{
|
||||
use super::event::{
|
||||
EndFileEvent, EndFileReason, HookEvent, LogMessageEvent, PropertyEvent, StartFileEvent,
|
||||
};
|
||||
use super::{ffi, Error, Event as MpvEvent, GetProperty, SetProperty};
|
||||
use event_listener::{Event, EventListener, IntoNotification};
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::ffi::{c_char, c_void, CStr, CString};
|
||||
use std::fmt;
|
||||
use std::pin::Pin;
|
||||
use std::ptr::NonNull;
|
||||
use tracing::{event, Level};
|
||||
|
||||
pub struct Handle {
|
||||
inner: NonNull<ffi::mpv_handle>,
|
||||
|
@ -254,7 +255,7 @@ impl Handle {
|
|||
|
||||
impl Drop for Handle {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping MpvHandle");
|
||||
event!(Level::DEBUG, "dropping MpvHandle");
|
||||
|
||||
// let any executor ticking tasks know we're ded
|
||||
self.wakeup.notify(u32::MAX.relaxed());
|
||||
|
@ -265,7 +266,7 @@ impl Drop for Handle {
|
|||
}
|
||||
// drain event queue (we're &mut so we know we have exclusive access)
|
||||
while let Some(event) = self.wait_event(0.0) {
|
||||
println!("drained event on drop: {event:?}");
|
||||
event!(Level::DEBUG, "drained event on drop: {:?}", event);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::mpv;
|
|||
use crate::signal::{Signal, SignalEmitter};
|
||||
use event_listener::EventListener;
|
||||
use std::cell::{Ref, RefCell};
|
||||
use tracing::{event, span, Level};
|
||||
use url::Url;
|
||||
|
||||
pub trait PlaybinEntry {
|
||||
|
@ -185,30 +186,36 @@ where
|
|||
}
|
||||
|
||||
fn handle_event(&self, event: mpv::Event) {
|
||||
let span = span!(Level::DEBUG, "mpv_handle_event");
|
||||
let _guart = span.enter();
|
||||
match event {
|
||||
mpv::Event::PropertyChange(event) => match event.reply_userdata {
|
||||
0 => {
|
||||
assert_eq!(&event.name, "volume");
|
||||
self.volume_changed.emit(self, ());
|
||||
dbg!(self.volume());
|
||||
event!(Level::DEBUG, "volume change {}", self.volume());
|
||||
}
|
||||
|
||||
1 => {
|
||||
assert_eq!(&event.name, "mute");
|
||||
self.muted_changed.emit(self, ());
|
||||
dbg!(self.muted());
|
||||
event!(Level::DEBUG, "mute state change to {}", self.muted());
|
||||
}
|
||||
|
||||
2 => {
|
||||
assert_eq!(&event.name, "pause");
|
||||
self.paused_changed.emit(self, ());
|
||||
dbg!(self.paused());
|
||||
event!(Level::DEBUG, "pause state change to {}", self.paused());
|
||||
}
|
||||
|
||||
3 => {
|
||||
assert_eq!(&event.name, "playlist-pos");
|
||||
self.current_entry_changed.emit(self, ());
|
||||
dbg!(self.current_entry());
|
||||
event!(
|
||||
Level::DEBUG,
|
||||
"playlist-pos change {:?}",
|
||||
self.current_entry()
|
||||
);
|
||||
}
|
||||
|
||||
_ => unreachable!(),
|
||||
|
@ -217,8 +224,8 @@ where
|
|||
mpv::Event::Hook(event) => match event.reply_userdata {
|
||||
0 => {
|
||||
assert_eq!(&event.name, "on_before_start_file");
|
||||
event!(Level::DEBUG, "on_before_start_file triggered");
|
||||
// just use this as a barrier
|
||||
println!("on_before_start_file triggered");
|
||||
self.mpv.continue_hook(event.id).unwrap();
|
||||
}
|
||||
|
||||
|
@ -237,7 +244,7 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
_ => println!("mpv event {:?}", event),
|
||||
_ => event!(Level::DEBUG, "mpv event {:?}", event),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,7 +279,7 @@ where
|
|||
|
||||
impl<E> Drop for Playbin<E> {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping Playbin2");
|
||||
event!(Level::DEBUG, "dropping Playbin2");
|
||||
self.mpv.command(["quit"]).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ pub mod schema;
|
|||
|
||||
use md5::Digest;
|
||||
use rand::Rng;
|
||||
use tracing::{event, Level};
|
||||
|
||||
fn runtime() -> &'static tokio::runtime::Runtime {
|
||||
static RUNTIME: std::sync::OnceLock<tokio::runtime::Runtime> = std::sync::OnceLock::new();
|
||||
|
@ -187,6 +188,6 @@ impl Client {
|
|||
|
||||
impl Drop for Client {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping SubsonicClient");
|
||||
event!(Level::DEBUG, "dropping SubsonicClient");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ mod imp {
|
|||
use glib::subclass::InitializingObject;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use tracing::{event, Level};
|
||||
|
||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||
#[template(resource = "/eu/callcc/audrey/play_queue.ui")]
|
||||
|
@ -99,7 +100,7 @@ mod imp {
|
|||
|
||||
impl Drop for PlayQueue {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiPlayQueue");
|
||||
event!(Level::DEBUG, "dropping AudreyUiPlayQueue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ mod imp {
|
|||
use glib::subclass::InitializingObject;
|
||||
use gtk::{gdk, glib};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use tracing::{event, Level};
|
||||
|
||||
#[derive(glib::Properties, gtk::CompositeTemplate, Default)]
|
||||
#[properties(wrapper_type = super::Playbar)]
|
||||
|
@ -160,7 +161,7 @@ mod imp {
|
|||
|
||||
impl Drop for Playbar {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiPlaybar");
|
||||
event!(Level::DEBUG, "dropping AudreyUiPlaybar");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ mod imp {
|
|||
use glib::subclass::InitializingObject;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use tracing::{event, Level};
|
||||
|
||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||
#[template(resource = "/eu/callcc/audrey/setup.ui")]
|
||||
|
@ -117,7 +118,7 @@ mod imp {
|
|||
|
||||
impl Drop for Setup {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiSetup");
|
||||
event!(Level::DEBUG, "dropping AudreyUiSetup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ mod imp {
|
|||
use gtk::{gdk, glib};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use tracing::{event, Level};
|
||||
|
||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||
#[template(resource = "/eu/callcc/audrey/window.ui")]
|
||||
|
@ -171,7 +172,7 @@ mod imp {
|
|||
|
||||
impl Drop for Window {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiWindow");
|
||||
event!(Level::DEBUG, "dropping AudreyUiWindow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue