feat(api): use tracing-actix logger middleware

- Completely move away from using traditional logs
This commit is contained in:
2024-05-08 23:50:03 -04:00
parent 444e42351e
commit 7b5fa61780
4 changed files with 23 additions and 3 deletions

View File

@@ -14,7 +14,6 @@ pub struct FormData {
// functions args isn't really relevant to the span
skip(form, db_conn_pool),
fields(
request_id = %Uuid::new_v4(),
subscriber_email = %form.email,
subscriber_name = %form.name
)

View File

@@ -1,9 +1,9 @@
use crate::routes::{healthcheck_route, subscribe_route};
use actix_web::dev::Server;
use actix_web::middleware::Logger;
use actix_web::{web, App, HttpServer};
use sqlx::PgPool;
use std::net::TcpListener;
use tracing_actix_web::TracingLogger;
pub fn run(listener: TcpListener, db_conn_pool: PgPool) -> Result<Server, std::io::Error> {
// under the hood, web::Data::new will create an Arc
@@ -12,7 +12,7 @@ pub fn run(listener: TcpListener, db_conn_pool: PgPool) -> Result<Server, std::i
let server = HttpServer::new(move || {
App::new()
.wrap(Logger::default())
.wrap(TracingLogger::default())
.route("/health_check", web::get().to(healthcheck_route))
.route("/subscriptions", web::post().to(subscribe_route))
.app_data(db_conn_pool.clone())