Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql async print sql logs ? #222

Open
qqliaoxin opened this issue Dec 23, 2022 · 4 comments
Open

mysql async print sql logs ? #222

qqliaoxin opened this issue Dec 23, 2022 · 4 comments

Comments

@qqliaoxin
Copy link

How does mysql async print sql logs

@blackbeam
Copy link
Owner

Could you please elaborate more on that? What do you mean by "print sql logs"?

@qqliaoxin
Copy link
Author

mysql async can output Sql from the console

@cloneable
Copy link
Contributor

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.

@i18nsite
Copy link

i18nsite commented Jan 19, 2024

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();
  }
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants