refactor: removed all imports of the log crate

This commit is contained in:
antifallobst 2024-03-30 19:19:58 +01:00
parent 28d3d03661
commit e7deb6e04c
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
5 changed files with 6 additions and 10 deletions

View File

@ -1,7 +1,6 @@
use crate::backend::Backend; use crate::backend::Backend;
use actix_web::{post, web, HttpResponse, Responder}; use actix_web::{post, web, HttpResponse, Responder};
use actix_web_httpauth::extractors::bearer::BearerAuth; use actix_web_httpauth::extractors::bearer::BearerAuth;
use log::error;
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
@ -13,7 +12,7 @@ struct NewResponse {
pub async fn new(backend: web::Data<Backend>, auth: BearerAuth) -> impl Responder { pub async fn new(backend: web::Data<Backend>, auth: BearerAuth) -> impl Responder {
match backend.create_invite_token(auth.token()).await { match backend.create_invite_token(auth.token()).await {
Err(e) => { Err(e) => {
error!("{e}"); log::error!("{e}");
HttpResponse::InternalServerError().finish() HttpResponse::InternalServerError().finish()
} }
Ok(res) => match res { Ok(res) => match res {

View File

@ -25,7 +25,7 @@ pub async fn register(
let body = body.into_inner(); let body = body.into_inner();
match backend.account_register(body.token, body.password).await { match backend.account_register(body.token, body.password).await {
Err(e) => { Err(e) => {
error!("{e}"); log::error!("{e}");
HttpResponse::InternalServerError().finish() HttpResponse::InternalServerError().finish()
} }
Ok(res) => match res { Ok(res) => match res {

View File

@ -3,7 +3,6 @@ pub mod relay_id;
use crate::backend::Backend; use crate::backend::Backend;
use actix_web::{post, web, HttpResponse, Responder}; use actix_web::{post, web, HttpResponse, Responder};
use actix_web_httpauth::extractors::bearer::BearerAuth; use actix_web_httpauth::extractors::bearer::BearerAuth;
use log::error;
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
@ -16,7 +15,7 @@ struct CreateResponse {
pub async fn create(backend: web::Data<Backend>, auth: BearerAuth) -> impl Responder { pub async fn create(backend: web::Data<Backend>, auth: BearerAuth) -> impl Responder {
match backend.create_relay(auth.token()).await { match backend.create_relay(auth.token()).await {
Err(e) => { Err(e) => {
error!("{e}"); log::error!("{e}");
HttpResponse::InternalServerError().finish() HttpResponse::InternalServerError().finish()
} }
Ok(res) => match res { Ok(res) => match res {

View File

@ -1,7 +1,6 @@
use crate::{backend::Backend, Base64Encoding}; use crate::{backend::Backend, Base64Encoding};
use actix_web::{get, web, HttpResponse, Responder}; use actix_web::{get, web, HttpResponse, Responder};
use actix_web_httpauth::extractors::bearer::BearerAuth; use actix_web_httpauth::extractors::bearer::BearerAuth;
use log::error;
use serde::Serialize; use serde::Serialize;
use std::str::FromStr; use std::str::FromStr;
use uuid::Uuid; use uuid::Uuid;
@ -32,7 +31,7 @@ pub async fn public_key(
.await .await
{ {
Err(e) => { Err(e) => {
error!("{e}"); log::error!("{e}");
HttpResponse::InternalServerError().finish() HttpResponse::InternalServerError().finish()
} }
Ok(res) => match res { Ok(res) => match res {

View File

@ -1,5 +1,4 @@
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use log::info;
use std::env; use std::env;
#[derive(Debug)] #[derive(Debug)]
@ -15,7 +14,7 @@ impl Config {
pub fn from_env() -> Result<Self> { pub fn from_env() -> Result<Self> {
Ok(Self { Ok(Self {
addr: env::var("CR_ADDRESS").unwrap_or_else(|_| { addr: env::var("CR_ADDRESS").unwrap_or_else(|_| {
info!("Using default address 0.0.0.0"); log::info!("Using default address 0.0.0.0");
"0.0.0.0".to_string() "0.0.0.0".to_string()
}), }),
port: match env::var("CR_PORT") { port: match env::var("CR_PORT") {
@ -23,7 +22,7 @@ impl Config {
Ok(port) => port, Ok(port) => port,
Err(_) => bail!("Failed to parse environment variable CR_PORT: '{str}' is not a valid port number!"), Err(_) => bail!("Failed to parse environment variable CR_PORT: '{str}' is not a valid port number!"),
}, },
Err(_) => { info!("Using default port 42069"); 42069 } Err(_) => { log::info!("Using default port 42069"); 42069 }
}, },
database: match env::var("CR_DATABASE") { database: match env::var("CR_DATABASE") {
Ok(db) => db, Ok(db) => db,