Open qqliaoxin opened 1 year ago
Could you please elaborate more on that? What do you mean by "print sql logs"?
mysql async can output Sql from the console
If you want to print all SQL to stdout you can now use the tracing feature and the FmtSubscriber from https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/index.html to log queries. Make sure tracing level DEBUG is enabled.
I add tracing , but not display sql
i use export RUST_LOG=debug
use atty::Stream;
use tracing_subscriber::{fmt::format::Writer, layer::SubscriberExt, EnvFilter};
pub struct NoTime;
impl tracing_subscriber::fmt::time::FormatTime for NoTime {
fn format_time(&self, _writer: &mut Writer<'_>) -> std::fmt::Result {
Ok(())
}
}
pub fn init() {
let env_filter = EnvFilter::from_default_env();
use tracing_subscriber::util::SubscriberInitExt;
let fmt = tracing_subscriber::fmt::layer()
.with_timer(NoTime)
.with_ansi(atty::is(Stream::Stdout));
tracing_subscriber::registry()
.with(fmt)
.with(env_filter)
.init();
}
How does mysql async print sql logs