Use non-blocking logging io and LTO in release

Also tweak README explanation of sqlx prepare.
This commit is contained in:
Tyler Hallada 2020-11-18 23:28:03 -05:00
parent b214786415
commit 0adbf7c5c0
4 changed files with 20 additions and 2 deletions

12
Cargo.lock generated
View File

@ -146,6 +146,7 @@ dependencies = [
"sqlx",
"tokio",
"tracing",
"tracing-appender",
"tracing-futures",
"tracing-subscriber",
"url",
@ -1889,6 +1890,17 @@ dependencies = [
"tracing-core",
]
[[package]]
name = "tracing-appender"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7aa52d56cc0d79ab604e8a022a1cebc4de33cf09dc9933c94353bea2e00d6e88"
dependencies = [
"chrono",
"crossbeam-channel",
"tracing-subscriber",
]
[[package]]
name = "tracing-attributes"
version = "0.1.11"

View File

@ -28,7 +28,11 @@ url = "2.1"
async-trait = "0.1"
seahash = "4.0"
tracing = "0.1"
tracing-appender = "0.1"
tracing-subscriber = "0.2"
tracing-futures = "0.2"
lru = "0.5"
http = "0.2"
[profile.release]
lto = true

View File

@ -195,7 +195,8 @@ A new migration can be created by running: `sqlx migrate add <name>`.
To allow the docker container for the API to get built in CI without a
database, the `sqlx-data.json` file needs to be re-generated every time the
database schema changes. It can be generated with `cargo sqlx prepare`.
database schema changes or any query is updated. It can be generated with `cargo
sqlx prepare`.
## Authentication

View File

@ -58,10 +58,11 @@ async fn main() -> Result<()> {
let env_log_filter =
env::var("RUST_LOG").unwrap_or_else(|_| "warp=info,bazaar_realm_api=info".to_owned());
let (non_blocking_writer, _guard) = tracing_appender::non_blocking(std::io::stdout());
tracing_subscriber::fmt()
.with_env_filter(env_log_filter)
.with_span_events(FmtSpan::CLOSE)
.with_writer(std::io::stdout)
.with_writer(non_blocking_writer)
.init();
let host = env::var("HOST").expect("`HOST` environment variable not defined");