Skip to content

Commit

Permalink
Debug log docs (SeaQL/sea-orm#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Sep 17, 2021
1 parent 6052c88 commit 26a17d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SeaORM/docs/01-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

1.3 [Connection Pool](/docs/install-and-config/connection)

1.4 [Debug Log](/docs/install-and-config/debug-log)

2. Generating Entities

2.1 [Using `sea-orm-cli`](/docs/generate-entity/sea-orm-cli)
Expand Down
20 changes: 20 additions & 0 deletions SeaORM/docs/02-install-and-config/04-debug-log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Debug Log

The SeaORM and the underlying database driver [`SQLx`](https://crates.io/crates/sqlx) both log debug messages via [`log`](https://crates.io/crates/log) crate.

You need to choose one of the [logging implementations](https://docs.rs/log/0.4.14/log/#available-logging-implementations) to capture and view the debug log. We recommand using [`env_logger`](https://crates.io/crates/env_logger), you can see the snippet below and a complete example [here](https://github.com/SeaQL/sea-orm/blob/master/examples/tokio/src/main.rs).

```rust
pub async fn main() {
env_logger::builder()
.filter_level(log::LevelFilter::Debug)
.is_test(true)
.init();

let db = Database::connect("mysql://sea:sea@localhost/bakery")
.await
.unwrap();

cake::Entity::find().one(&db).await.unwrap();
}
```

0 comments on commit 26a17d9

Please sign in to comment.