mirror of
https://github.com/danbulant/cushy
synced 2026-07-06 19:50:40 +00:00
Embracing tracing
This commit is contained in:
parent
ad57e02e4f
commit
9596eaac17
5 changed files with 140 additions and 7 deletions
106
Cargo.lock
generated
106
Cargo.lock
generated
|
|
@ -638,6 +638,8 @@ dependencies = [
|
||||||
"kempt",
|
"kempt",
|
||||||
"kludgine",
|
"kludgine",
|
||||||
"pollster",
|
"pollster",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1148,6 +1150,16 @@ dependencies = [
|
||||||
"minimal-lexical",
|
"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]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
|
|
@ -1265,6 +1277,12 @@ dependencies = [
|
||||||
"libredox",
|
"libredox",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "overload"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owned_ttf_parser"
|
name = "owned_ttf_parser"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
|
|
@ -1309,6 +1327,12 @@ version = "2.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
|
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.27"
|
version = "0.3.27"
|
||||||
|
|
@ -1528,6 +1552,15 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sharded-slab"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slotmap"
|
name = "slotmap"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
|
@ -1670,6 +1703,16 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thread_local"
|
||||||
|
version = "1.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-skia"
|
name = "tiny-skia"
|
||||||
version = "0.11.2"
|
version = "0.11.2"
|
||||||
|
|
@ -1727,6 +1770,63 @@ dependencies = [
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing"
|
||||||
|
version = "0.1.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
|
||||||
|
dependencies = [
|
||||||
|
"pin-project-lite",
|
||||||
|
"tracing-attributes",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-attributes"
|
||||||
|
version = "0.1.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-core"
|
||||||
|
version = "0.1.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"valuable",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-log"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-subscriber"
|
||||||
|
version = "0.3.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
|
||||||
|
dependencies = [
|
||||||
|
"nu-ansi-term",
|
||||||
|
"sharded-slab",
|
||||||
|
"smallvec",
|
||||||
|
"thread_local",
|
||||||
|
"tracing-core",
|
||||||
|
"tracing-log",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttf-parser"
|
name = "ttf-parser"
|
||||||
version = "0.19.2"
|
version = "0.19.2"
|
||||||
|
|
@ -1799,6 +1899,12 @@ version = "0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "valuable"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vec_map"
|
name = "vec_map"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ name = "gooey"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
[features]
|
||||||
|
default = ["tracing-output"]
|
||||||
|
tracing-output = ["dep:tracing-subscriber"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kludgine = { git = "https://github.com/khonsulabs/kludgine", features = [
|
kludgine = { git = "https://github.com/khonsulabs/kludgine", features = [
|
||||||
|
|
@ -13,6 +15,10 @@ alot = "0.3"
|
||||||
interner = "0.2.1"
|
interner = "0.2.1"
|
||||||
kempt = "0.2.1"
|
kempt = "0.2.1"
|
||||||
intentional = "0.1.0"
|
intentional = "0.1.0"
|
||||||
|
tracing = "0.1.40"
|
||||||
|
|
||||||
|
tracing-subscriber = { version = "0.3", optional = true }
|
||||||
|
|
||||||
|
|
||||||
# [patch."https://github.com/khonsulabs/kludgine"]
|
# [patch."https://github.com/khonsulabs/kludgine"]
|
||||||
# kludgine = { path = "../kludgine2" }
|
# kludgine = { path = "../kludgine2" }
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ impl<'context, 'window> EventContext<'context, 'window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if activation_changes == MAX_ITERS {
|
if activation_changes == MAX_ITERS {
|
||||||
eprintln!(
|
tracing::error!(
|
||||||
"activation change force stopped after {activation_changes} sequential changes"
|
"activation change force stopped after {activation_changes} sequential changes"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ impl<'context, 'window> EventContext<'context, 'window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if focus_changes == MAX_ITERS {
|
if focus_changes == MAX_ITERS {
|
||||||
eprintln!("focus change force stopped after {focus_changes} sequential changes");
|
tracing::error!("focus change force stopped after {focus_changes} sequential changes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
16
src/lib.rs
16
src/lib.rs
|
|
@ -136,3 +136,19 @@ macro_rules! styles {
|
||||||
$crate::styles!($($component => $value),*)
|
$crate::styles!($($component => $value),*)
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn initialize_tracing() {
|
||||||
|
#[cfg(feature = "tracing-output")]
|
||||||
|
{
|
||||||
|
use tracing::Level;
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
const MAX_LEVEL: Level = Level::DEBUG;
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
const MAX_LEVEL: Level = Level::ERROR;
|
||||||
|
|
||||||
|
let _result = tracing_subscriber::fmt::fmt()
|
||||||
|
.with_max_level(MAX_LEVEL)
|
||||||
|
.try_init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ use kludgine::figures::units::Px;
|
||||||
use kludgine::figures::{IntoSigned, Point, Rect, Size};
|
use kludgine::figures::{IntoSigned, Point, Rect, Size};
|
||||||
use kludgine::render::Drawing;
|
use kludgine::render::Drawing;
|
||||||
use kludgine::Kludgine;
|
use kludgine::Kludgine;
|
||||||
|
use tracing::Level;
|
||||||
|
|
||||||
use crate::context::{
|
use crate::context::{
|
||||||
AsEventContext, EventContext, Exclusive, GraphicsContext, LayoutContext, RedrawStatus,
|
AsEventContext, EventContext, Exclusive, GraphicsContext, LayoutContext, RedrawStatus,
|
||||||
|
|
@ -34,7 +35,7 @@ use crate::widget::{
|
||||||
EventHandling, ManagedWidget, Widget, WidgetId, WidgetInstance, HANDLED, IGNORED,
|
EventHandling, ManagedWidget, Widget, WidgetId, WidgetInstance, HANDLED, IGNORED,
|
||||||
};
|
};
|
||||||
use crate::window::sealed::WindowCommand;
|
use crate::window::sealed::WindowCommand;
|
||||||
use crate::{ConstraintLimit, Run};
|
use crate::{initialize_tracing, ConstraintLimit, Run};
|
||||||
|
|
||||||
/// A currently running Gooey window.
|
/// A currently running Gooey window.
|
||||||
pub struct RunningWindow<'window> {
|
pub struct RunningWindow<'window> {
|
||||||
|
|
@ -191,6 +192,7 @@ where
|
||||||
Behavior: WindowBehavior,
|
Behavior: WindowBehavior,
|
||||||
{
|
{
|
||||||
fn run(self) -> crate::Result {
|
fn run(self) -> crate::Result {
|
||||||
|
initialize_tracing();
|
||||||
GooeyWindow::<Behavior>::run_with(AssertUnwindSafe(sealed::Context {
|
GooeyWindow::<Behavior>::run_with(AssertUnwindSafe(sealed::Context {
|
||||||
user: self.context,
|
user: self.context,
|
||||||
settings: RefCell::new(sealed::WindowSettings {
|
settings: RefCell::new(sealed::WindowSettings {
|
||||||
|
|
@ -517,9 +519,12 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
tracing::event!(
|
||||||
"Ignored Keyboard Input: {:?} ({:?}); {:?}",
|
Level::DEBUG,
|
||||||
input.logical_key, input.physical_key, input.state
|
logical = ?input.logical_key,
|
||||||
|
physical = ?input.physical_key,
|
||||||
|
state = ?input.state,
|
||||||
|
"Ignored Keyboard Input",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue