chore: log spawned actor details on single line
This commit is contained in:
parent
8a3b092126
commit
20fbce0cf0
1 changed files with 22 additions and 4 deletions
|
@ -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
|
||||
}};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue