Skip to content

Commit

Permalink
Reduce noise logs while running tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
linw1995 committed Aug 6, 2024
1 parent ea0c47f commit 5634f99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
RUST_LOG: debug
RUST_LOG: bearmark=debug,rocket=info

- name: Upload to codecov.io
uses: codecov/codecov-action@v4
Expand Down
12 changes: 10 additions & 2 deletions src/db/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ pub async fn establish() -> AsyncPgConnection {

if cfg!(debug_assertions) {
use diesel::connection::InstrumentationEvent;
use tracing::debug;
conn.set_instrumentation(|event: InstrumentationEvent<'_>| debug!(?event));
conn.set_instrumentation(|event: InstrumentationEvent<'_>| match event {
InstrumentationEvent::StartQuery { query, .. } => {
tracing::info!("Executing query: {}", query);
}
InstrumentationEvent::FinishQuery { query, error, .. } => match error {
Some(e) => tracing::error!("Query failed: {}\nError: {:?}", query, e),
None => tracing::debug!("Executing query succeeded: {}", query),
},
_ => {}
});
}

conn
Expand Down

0 comments on commit 5634f99

Please sign in to comment.