aboutsummaryrefslogtreecommitdiff
path: root/macros/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-08-13 11:26:37 +0200
committerHampusM <hampus@hampusmat.com>2023-08-13 11:26:37 +0200
commit8f990a4477aa126e6bc79b98ba5f6685b0658fe7 (patch)
tree9ea852d71f3afa201f5633eb789ff488c6df1358 /macros/src/lib.rs
parent89c238f9c82ade2d7656e2bee76838a391609a88 (diff)
feat: add internal logging for macros
Diffstat (limited to 'macros/src/lib.rs')
-rw-r--r--macros/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs
index 2fc3c21..41001ae 100644
--- a/macros/src/lib.rs
+++ b/macros/src/lib.rs
@@ -482,6 +482,9 @@ pub fn declare_interface(input: TokenStream) -> TokenStream
.map_or_else(|| Ok(false), MacroFlag::get_bool)
.unwrap_or_abort();
+ #[cfg(syrette_macros_logging)]
+ init_logging();
+
let interface_type = if interface == implementation {
Type::Path(interface)
} else {
@@ -545,3 +548,18 @@ pub fn named(_: TokenStream, _: TokenStream) -> TokenStream
{
TokenStream::new()
}
+
+#[cfg(syrette_macros_logging)]
+fn init_logging()
+{
+ use tracing::Level;
+ use tracing_subscriber::FmtSubscriber;
+
+ let subscriber = FmtSubscriber::builder()
+ .with_max_level(Level::DEBUG)
+ .finish();
+
+ // The error can be ignored because it doesn't matter if the global default
+ // has already been set
+ tracing::subscriber::set_global_default(subscriber).ok();
+}