Closed dtzxporter closed 2 years ago
Hello,
Using tracing
should be optional and available as a feature.
I think there could be a logger
macro with two implementations gated by #[cfg(feature = "tracing")]
and #[cfg(not(feature = "tracing"))]
.
Similarly, configure_logging
could be made available or not, and in case it is not regular logging should be enabled.
Sure, what would you like the default to be, log, or tracing?
I think log
is a better default.
Sure, give me a few and I'll make the req changes
Let me know if these changes work for you!
Let me give it a try on your branch to confirm my latest comments
Sure, for the macro thing, I wasn't able to do so... I want macros 2.0 already :D
So I confirm my comments are valid, here is a patch that passes the tests:
Drop for RtcPeerConnection
{
fn drop(&mut self) {
if let Err(err) = check(unsafe { sys::rtcDeletePeerConnection(self.id) }) {
- error!(
+ logger::error!(
"Error while dropping RtcPeerConnection id={} {:p}: {}",
- self.id, self, err
+ self.id,
+ self,
+ err
)
}
}
diff --git a/src/track.rs b/src/track.rs
index 34fcfe0..8916780 100644
--- a/src/track.rs
+++ b/src/track.rs
@@ -5,6 +5,7 @@ use std::slice;
use datachannel_sys as sys;
use crate::error::{check, Result};
+use crate::logger;
#[derive(Debug, Clone, Copy)]
pub enum Direction {
@@ -168,9 +169,11 @@ where
impl
Ahh yes, you can do that when you re-export the existing macros, I was confirming to your original comment about "making a macro" which doesn't work the way you described.
However there is an issue with the current approach:
# works
cargo test
# works
cargo test --no-default-features --features tracing
# does NOT work
cargo test --features tracing
# does NOT work
cargo test --no-default-features
So all the above have to work. I'll try to think of something for that.
Ahh yes, you can do that when you re-export the existing macros, I was confirming to your original comment about "making a macro" which doesn't work the way you described.
You're right I wasn't clear, sorry for that.
Perhaps we take inspiration from libraries that have async-std/tokio support? A custom error message:
#[cfg(not(any(
feature = "runtime-actix-native-tls",
feature = "runtime-async-std-native-tls",
feature = "runtime-tokio-native-tls",
feature = "runtime-actix-rustls",
feature = "runtime-async-std-rustls",
feature = "runtime-tokio-rustls",
)))]
compile_error!(
"one of the features ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \
'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \
'runtime-tokio-rustls'] must be enabled"
);
#[cfg(any(
all(feature = "_rt-actix", feature = "_rt-async-std"),
all(feature = "_rt-actix", feature = "_rt-tokio"),
all(feature = "_rt-async-std", feature = "_rt-tokio"),
all(feature = "_tls-native-tls", feature = "_tls-rustls"),
))]
compile_error!(
"only one of ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \
'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \
'runtime-tokio-rustls'] can be enabled"
);
That's a good idea !
Added + reworked to just reexport the macros from logger.
I think there are some
#[cfg(feature = "log")]
use log::*;
#[cfg(feature = "tracing")]
use tracing::*;
remaining in the tests
I think there are some
#[cfg(feature = "log")] use log::*; #[cfg(feature = "tracing")] use tracing::*;
remaining in the tests
So I can import logging
but only if I make it public from datachannel... crate
in a test is it's own module.
Maybe:
#[cfg(feature = "log")]
use log as logger;
#[cfg(feature = "tracing")]
use tracing as logger;
?
Thanks ! I'll release it later today.
Released in 0.7.4
tracing
orlog
based on features0.12
.tracing-subscriber
.