Swap out old log for shiny tracing

This commit is contained in:
2020-07-27 22:36:48 -04:00
parent fb99afdc26
commit b16ba3e3f7
8 changed files with 259 additions and 172 deletions

View File

@@ -1,6 +1,3 @@
#[macro_use]
extern crate log;
use anyhow::Result;
use clap::Clap;
use dotenv::dotenv;
@@ -10,6 +7,8 @@ use serde::Serialize;
use sqlx::postgres::PgPool;
use std::convert::Infallible;
use std::env;
use tracing::info;
use tracing_subscriber::fmt::format::FmtSpan;
use url::Url;
use warp::Filter;
@@ -53,10 +52,12 @@ struct ErrorMessage {
#[tokio::main]
async fn main() -> Result<()> {
dotenv().ok();
if env::var_os("RUST_LOG").is_none() {
env::set_var("RUST_LOG", "shopkeeper=info");
}
pretty_env_logger::init();
let env_log_filter =
env::var("RUST_LOG").unwrap_or_else(|_| "warp=info,shopkeeper=info".to_owned());
tracing_subscriber::fmt()
.with_env_filter(env_log_filter)
.with_span_events(FmtSpan::CLOSE)
.init();
let opts: Opts = Opts::parse();
if opts.migrate {
@@ -96,7 +97,7 @@ async fn main() -> Result<()> {
)
.recover(problem::unpack_problem)
.with(warp::compression::gzip())
.with(warp::log("shopkeeper"));
.with(warp::trace::request());
let svc = warp::service(routes);
let make_svc = hyper::service::make_service_fn(|_: _| {