Swap out old log for shiny tracing
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -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(|_: _| {
|
||||
|
||||
Reference in New Issue
Block a user