Add observability using the tracing crate

This commit is contained in:
2022-01-10 14:41:11 +01:00
parent cd9c4a3553
commit 807924dd8d
10 changed files with 364 additions and 192 deletions

View File

@@ -1,21 +1,20 @@
extern crate dotenv;
extern crate env_logger;
extern crate listenfd;
use contextswitch_api::run;
use contextswitch_api::observability::{get_subscriber, init_subscriber};
use contextswitch_api::{run, taskwarrior};
use dotenv::dotenv;
use std::env;
use std::net::TcpListener;
pub mod taskwarrior;
#[actix_web::main]
#[tokio::main]
async fn main() -> std::io::Result<()> {
env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let subscriber = get_subscriber("info".into());
init_subscriber(subscriber);
dotenv().ok();
let port = env::var("PORT").unwrap_or("8000".to_string());
let port = env::var("PORT").unwrap_or_else(|_| "8000".to_string());
taskwarrior::load_config(None);
let listener = TcpListener::bind(format!("0.0.0.0:{}", port)).expect("Failed to bind port");