pretty tracing

This commit is contained in:
nora 2023-11-08 21:32:54 +01:00
parent 9575dc4138
commit ba5e53eea6
10 changed files with 327 additions and 18 deletions

12
test-program/Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[package]
name = "test-program"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
tracing-tree = "0.2.5"
uwuwind = { path = ".." }

49
test-program/src/main.rs Normal file
View file

@ -0,0 +1,49 @@
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
use tracing_subscriber::util::SubscriberInitExt;
use uwuwind::uw;
#[repr(C)]
struct Exception {
_uwe: uw::_Unwind_Exception,
uwu: &'static str,
}
fn main() {
let registry = tracing_subscriber::Registry::default().with(
EnvFilter::builder()
.with_default_directive(tracing::Level::TRACE.into())
.from_env()
.unwrap(),
);
let tree_layer = tracing_tree::HierarchicalLayer::new(2)
.with_targets(true)
.with_bracketed_fields(true);
registry.with(tree_layer).init();
unsafe {
uwuwind::set_personality_routine(personality_routine);
let exception = Box::into_raw(Box::new(Exception {
_uwe: uw::_Unwind_Exception {
exception_class: 123456,
exception_cleanup0: |_, _| {},
private_1: 0,
private_2: 0,
},
uwu: "meow :3",
}));
uwuwind::_UnwindRaiseException(exception.cast::<uw::_Unwind_Exception>());
}
}
fn personality_routine(
_version: i32,
_actions: uw::_UnwindAction,
_exception_class: u64,
_exception_object: *mut uw::_Unwind_Exception,
_context: *mut uw::_Unwind_Context,
) -> uw::_Unwind_Reason_Code {
uw::_Unwind_Reason_Code::_URC_NO_REASON
}