chore: log spawned actor details on single line
Some checks failed
Test / build (map[name:nightly]) (push) Successful in 4m7s
Test / build (map[name:stable]) (push) Successful in 3m53s
Release Please / Release-plz (push) Failing after 34s

This commit is contained in:
Paul Campbell 2024-12-23 08:01:44 +00:00
parent 8a3b092126
commit 20fbce0cf0

View file

@ -3,23 +3,41 @@
#[macro_export]
macro_rules! spawn {
($parent:expr, $actor:expr) => {{
tracing::debug!("spawning : {}", stringify!($actor));
tracing::debug!("spawning : {}", $crate::stringify_expr!($actor));
let new_actor_ref = kameo::spawn($actor);
new_actor_ref.link(&$parent).await;
$parent.link(&new_actor_ref).await;
tracing::debug!("spawned : {}", stringify!($actor));
tracing::debug!("spawned : {}", $crate::stringify_expr!($actor));
new_actor_ref
}};
}
#[macro_export]
macro_rules! stringify_expr {
($expr:expr) => {
stringify!($expr).lines().collect::<Vec<_>>().join(" ")
};
}
#[test]
fn remove_line_breaks() {
let out = stringify_expr!([
"line 1", "line 2", "line 3", "line 1", "line 2", "line 3", "line 1", "line 2", "line 3",
"line 1", "line 2", "line 3",
]);
let expected = r#"["line 1", "line 2", "line 3", "line 1", "line 2", "line 3", "line 1", "line 2", "line 3", "line 1", "line 2", "line 3",]"#;
assert_eq!(out, expected);
}
#[macro_export]
macro_rules! spawn_in_thread {
($parent:expr, $actor:expr) => {{
tracing::debug!("spawning in thread : {}", stringify!($actor));
tracing::debug!("spawning in thread : {}", $crate::stringify_expr!($actor));
let new_actor_ref = kameo::actor::spawn_in_thread($actor);
new_actor_ref.link(&$parent).await;
$parent.link(&new_actor_ref).await;
tracing::debug!("spawned in thread : {}", stringify!($actor));
tracing::debug!("spawned in thread : {}", $crate::stringify_expr!($actor));
new_actor_ref
}};
}