From dc5164f779171420056cdf02a7976d608ec8ef62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Wo=C5=BAniak?= Date: Fri, 13 Aug 2021 12:56:11 +0200 Subject: [PATCH] Unify dependencies --- Cargo.lock | 21 +++------------------ actors/database-actor/Cargo.toml | 4 ---- actors/database-actor/src/issues.rs | 6 +++--- actors/database-actor/src/lib.rs | 8 ++++---- actors/database-actor/src/prelude.rs | 18 +++++++++--------- actors/filesystem-actor/Cargo.toml | 4 ---- actors/highlight-actor/Cargo.toml | 4 ---- actors/mail-actor/Cargo.toml | 4 ---- actors/web-actor/Cargo.toml | 4 ---- actors/web-actor/src/avatar.rs | 8 ++++---- actors/web-actor/src/lib.rs | 3 --- actors/websocket-actor/Cargo.toml | 4 ---- actors/websocket-actor/src/lib.rs | 7 ++----- actors/websocket-actor/src/prelude.rs | 12 ++++++------ actors/websocket-actor/src/server/mod.rs | 5 +++-- derive/derive_db_execute/src/lib.rs | 10 +++++----- shared/common/Cargo.toml | 4 ++++ shared/common/src/lib.rs | 5 ++++- 18 files changed, 47 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6defa209..7235fe03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -892,6 +892,9 @@ dependencies = [ "actix-web", "actix-web-actors", "actix_derive 0.6.0", + "env_logger", + "log", + "pretty_env_logger", "reexport-proc-macro", "serde", "serde_derive", @@ -1034,20 +1037,17 @@ dependencies = [ "derive_db_execute", "diesel", "dotenv", - "env_logger", "futures", "ipnetwork 0.16.0", "jirs-config", "jirs-data", "libc", - "log", "num-bigint", "num-integer", "num-traits", "openssl-sys", "percent-encoding", "pq-sys", - "pretty_env_logger", "r2d2", "serde", "time 0.1.44", @@ -1362,11 +1362,8 @@ dependencies = [ "actix-files", "bytes 0.5.6", "common", - "env_logger", "futures", "jirs-config", - "log", - "pretty_env_logger", "tokio", ] @@ -1689,13 +1686,10 @@ dependencies = [ "actix 0.10.0", "bincode", "common", - "env_logger", "flate2", "jirs-config", "jirs-data", "lazy_static", - "log", - "pretty_env_logger", "serde", "simsearch", "syntect", @@ -2133,15 +2127,12 @@ dependencies = [ "actix 0.10.0", "common", "dotenv", - "env_logger", "futures", "jirs-config", "lettre", "lettre_email", "libc", - "log", "openssl-sys", - "pretty_env_logger", "serde", "toml", "uuid 0.8.2", @@ -4226,16 +4217,13 @@ dependencies = [ "bytes 0.5.6", "common", "database-actor", - "env_logger", "filesystem-actor", "futures", "jirs-config", "jirs-data", "libc", - "log", "mail-actor", "openssl-sys", - "pretty_env_logger", "serde", "tokio", "toml", @@ -4262,7 +4250,6 @@ dependencies = [ "common", "comrak", "database-actor", - "env_logger", "flate2", "futures", "highlight-actor", @@ -4270,10 +4257,8 @@ dependencies = [ "jirs-data", "lazy_static", "libc", - "log", "mail-actor", "openssl-sys", - "pretty_env_logger", "pulldown-cmark", "serde", "syntect", diff --git a/actors/database-actor/Cargo.toml b/actors/database-actor/Cargo.toml index a9f2c30d..11ef3d7b 100644 --- a/actors/database-actor/Cargo.toml +++ b/actors/database-actor/Cargo.toml @@ -42,10 +42,6 @@ num-integer = { version = "0.1.32" } bigdecimal = { version = ">= 0.0.10, <= 0.1.0" } bitflags = { version = "1.0" } -log = "0.4" -pretty_env_logger = "0.4" -env_logger = "0.7" - [dependencies.jirs-config] path = "../../shared/jirs-config" features = ["database"] diff --git a/actors/database-actor/src/issues.rs b/actors/database-actor/src/issues.rs index 6b5bfe5a..5b3927d4 100644 --- a/actors/database-actor/src/issues.rs +++ b/actors/database-actor/src/issues.rs @@ -88,7 +88,7 @@ impl UpdateIssue { )) .get_result(conn) .map_err(|e| { - log::debug!("{:?}", e); + common::log::debug!("{:?}", e); crate::DatabaseError::GenericFailure( crate::OperationError::Create, crate::ResourceKind::Issue, @@ -186,7 +186,7 @@ impl CreateIssue { .select(sql("COALESCE(max(list_position), 0) + 1")) .get_result::(conn) .map_err(|e| { - log::error!("resolve new issue position failed {}", e); + common::log::error!("resolve new issue position failed {}", e); crate::DatabaseError::Issue(crate::IssueError::BadListPosition) })?; let i_s_id: IssueStatusId = if msg.issue_status_id == 0 { @@ -230,7 +230,7 @@ impl CreateIssue { } .execute(conn)?; issues.find(issue.id).get_result(conn).map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); crate::DatabaseError::GenericFailure( crate::OperationError::Create, crate::ResourceKind::Issue, diff --git a/actors/database-actor/src/lib.rs b/actors/database-actor/src/lib.rs index 0b704bad..cfda5424 100644 --- a/actors/database-actor/src/lib.rs +++ b/actors/database-actor/src/lib.rs @@ -75,7 +75,7 @@ impl<'l> Guard<'l> { use diesel::prelude::*; let tm = conn.transaction_manager(); tm.begin_transaction(conn).map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); crate::DatabaseError::DatabaseConnectionLost })?; Ok(Self { conn, tm }) @@ -91,15 +91,15 @@ impl<'l> Guard<'l> { match r { Ok(r) => { self.tm.commit_transaction(self.conn).map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); crate::DatabaseError::DatabaseConnectionLost })?; Ok(r) } Err(e) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); self.tm.rollback_transaction(self.conn).map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); crate::DatabaseError::DatabaseConnectionLost })?; Err(e) diff --git a/actors/database-actor/src/prelude.rs b/actors/database-actor/src/prelude.rs index cf6199d3..2c27a97f 100644 --- a/actors/database-actor/src/prelude.rs +++ b/actors/database-actor/src/prelude.rs @@ -2,13 +2,13 @@ macro_rules! db_pool { ($self: expr) => { &$self.pool.get().map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::DatabaseConnectionLost })? }; ($self: expr, $pool: expr) => { &$pool.get().map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::DatabaseConnectionLost })? }; @@ -18,7 +18,7 @@ macro_rules! db_pool { macro_rules! q { ($q: expr) => {{ let q = $q; - log::debug!( + common::log::debug!( "{}", diesel::debug_query::(&q).to_string() ); @@ -40,7 +40,7 @@ macro_rules! db_find { $crate::q!($q) .first($conn) .map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::GenericFailure( $crate::OperationError::LoadCollection, $crate::ResourceKind::$resource, @@ -81,7 +81,7 @@ macro_rules! db_load { $crate::q!($q) .load(conn) .map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::GenericFailure( $crate::OperationError::LoadCollection, $crate::ResourceKind::$resource, @@ -120,7 +120,7 @@ macro_rules! db_load_field { $crate::q!($q) .load(conn) .map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::GenericFailure( $crate::OperationError::LoadCollection, $crate::ResourceKind::$resource, @@ -162,7 +162,7 @@ macro_rules! db_create { $crate::q!($q) .get_result::<$resource>($conn) .map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::GenericFailure( $crate::OperationError::Create, $crate::ResourceKind::$resource, @@ -205,7 +205,7 @@ macro_rules! db_update { $crate::q!($q) .get_result::<$resource>($conn) .map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::GenericFailure( $crate::OperationError::Update, $crate::ResourceKind::$resource, @@ -247,7 +247,7 @@ macro_rules! db_delete { $crate::q!($q) .execute($conn) .map_err(|e| { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $crate::DatabaseError::GenericFailure( $crate::OperationError::Delete, $crate::ResourceKind::$resource, diff --git a/actors/filesystem-actor/Cargo.toml b/actors/filesystem-actor/Cargo.toml index 05a00bba..3273a4bf 100644 --- a/actors/filesystem-actor/Cargo.toml +++ b/actors/filesystem-actor/Cargo.toml @@ -18,10 +18,6 @@ actix = { version = "0.10.0" } futures = { version = "0.3.8" } -log = "0.4" -pretty_env_logger = "0.4" -env_logger = "0.7" - bytes = { version = "0.5.6" } # Local storage diff --git a/actors/highlight-actor/Cargo.toml b/actors/highlight-actor/Cargo.toml index 026bb14a..767d2563 100644 --- a/actors/highlight-actor/Cargo.toml +++ b/actors/highlight-actor/Cargo.toml @@ -26,10 +26,6 @@ flate2 = { version = "*" } syntect = { version = "*" } lazy_static = { version = "*" } -log = "0.4" -pretty_env_logger = "0.4" -env_logger = "0.7" - [dependencies.jirs-config] path = "../../shared/jirs-config" features = ["hi"] diff --git a/actors/mail-actor/Cargo.toml b/actors/mail-actor/Cargo.toml index f41c5d6d..586ac8c4 100644 --- a/actors/mail-actor/Cargo.toml +++ b/actors/mail-actor/Cargo.toml @@ -19,10 +19,6 @@ actix = { version = "0.10.0" } serde = "*" toml = { version = "*" } -log = "0.4" -pretty_env_logger = "0.4" -env_logger = "0.7" - dotenv = { version = "*" } uuid = { version = "0.8.1", features = ["serde", "v4", "v5"] } diff --git a/actors/web-actor/Cargo.toml b/actors/web-actor/Cargo.toml index d1f5302f..508e5fc6 100644 --- a/actors/web-actor/Cargo.toml +++ b/actors/web-actor/Cargo.toml @@ -33,10 +33,6 @@ futures = { version = "0.3.8" } openssl-sys = { version = "*", features = ["vendored"] } libc = { version = "0.2.0", default-features = false } -log = "0.4" -pretty_env_logger = "0.4" -env_logger = "0.7" - uuid = { version = "0.8.1", features = ["serde", "v4", "v5"] } [dependencies.jirs-config] diff --git a/actors/web-actor/src/avatar.rs b/actors/web-actor/src/avatar.rs index 340eaea8..3f5fa539 100644 --- a/actors/web-actor/src/avatar.rs +++ b/actors/web-actor/src/avatar.rs @@ -160,13 +160,13 @@ async fn update_user_avatar( Ok(Ok(user)) => Ok(user), Ok(Err(e)) => { - error!("{:?}", e); + common::log::error!("{:?}", e); Err(actix_web::Error::from( HttpResponse::Unauthorized().finish(), )) } Err(e) => { - error!("{:?}", e); + common::log::error!("{:?}", e); Err(actix_web::Error::from( HttpResponse::Unauthorized().finish(), )) @@ -191,11 +191,11 @@ async fn handle_token( Ok(Ok(user)) => Ok(user.id), Ok(Err(e)) => { - error!("{:?}", e); + common::log::error!("{:?}", e); Err(HttpResponse::Unauthorized().finish().into()) } Err(e) => { - error!("{:?}", e); + common::log::error!("{:?}", e); Err(HttpResponse::Unauthorized().finish().into()) } } diff --git a/actors/web-actor/src/lib.rs b/actors/web-actor/src/lib.rs index 3f0daad6..7bfc8ba4 100644 --- a/actors/web-actor/src/lib.rs +++ b/actors/web-actor/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate log; - use actix::Addr; use actix_web::web::Data; use actix_web::{HttpRequest, HttpResponse}; diff --git a/actors/websocket-actor/Cargo.toml b/actors/websocket-actor/Cargo.toml index be081f04..9a66909b 100644 --- a/actors/websocket-actor/Cargo.toml +++ b/actors/websocket-actor/Cargo.toml @@ -28,10 +28,6 @@ flate2 = { version = "*" } syntect = { version = "*" } lazy_static = { version = "*" } -log = { version = "0.4" } -pretty_env_logger = { version = "0.4" } -env_logger = { version = "0.7" } - uuid = { version = "0.8.1", features = ["serde", "v4", "v5"] } [dependencies.comrak] diff --git a/actors/websocket-actor/src/lib.rs b/actors/websocket-actor/src/lib.rs index 0be0edf9..a09a14dd 100644 --- a/actors/websocket-actor/src/lib.rs +++ b/actors/websocket-actor/src/lib.rs @@ -1,17 +1,14 @@ -#[macro_use] -extern crate log; - use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Recipient, StreamHandler}; use actix_web::web::{self, Data}; use actix_web::{get, Error, HttpRequest, HttpResponse}; use actix_web_actors::ws; +use common::log::*; use common::{actix_web, actix_web_actors}; use database_actor::projects::LoadCurrentProject; use database_actor::user_projects::CurrentUserProject; use database_actor::DbExecutor; use futures::executor::block_on; use jirs_data::{Project, User, UserProject, WsMsg}; -use log::*; use mail_actor::MailExecutor; use crate::handlers::*; @@ -47,7 +44,7 @@ impl WsMessageSender for ws::WebsocketContext { fn send_msg(&mut self, msg: &WsMsg) { match bincode::serialize(msg) { Err(err) => { - log::error!("{}", err); + common::log::error!("{}", err); } Ok(v) => self.binary(v), } diff --git a/actors/websocket-actor/src/prelude.rs b/actors/websocket-actor/src/prelude.rs index 5e670b76..3eeea0b8 100644 --- a/actors/websocket-actor/src/prelude.rs +++ b/actors/websocket-actor/src/prelude.rs @@ -34,11 +34,11 @@ macro_rules! actor_or_debug_and_return { match block_on($s.$actor.send($msg)) { Ok(Ok(r)) => r, Ok(Err(e)) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); return $actor_err; } Err(e) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); return $mailbox_err; } } @@ -56,10 +56,10 @@ macro_rules! actor_or_debug_and_ignore { $on_success(r); } Ok(Err(e)) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); } Err(e) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); } } }; @@ -71,11 +71,11 @@ macro_rules! actor_or_debug_and_fallback { match block_on($s.$actor.send($msg)) { Ok(Ok(r)) => r, Ok(Err(e)) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $actor_err } Err(e) => { - log::error!("{:?}", e); + common::log::error!("{:?}", e); $mailbox_err } } diff --git a/actors/websocket-actor/src/server/mod.rs b/actors/websocket-actor/src/server/mod.rs index 6b056d8c..50ec33ab 100644 --- a/actors/websocket-actor/src/server/mod.rs +++ b/actors/websocket-actor/src/server/mod.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use actix::{Actor, Context, Recipient}; +use common::log::*; use jirs_data::{ProjectId, UserId, WsMsg}; #[derive(actix::Message, Debug)] @@ -110,8 +111,8 @@ impl WsServer { fn send_to_recipients(&self, recipients: &[Recipient], msg: &WsMsg) { for recipient in recipients.iter() { match recipient.do_send(InnerMsg::Transfer(msg.clone())) { - Ok(_) => debug!("msg sent"), - Err(e) => error!("{}", e), + Ok(_) => common::log::debug!("msg sent"), + Err(e) => common::log::error!("{}", e), }; } } diff --git a/derive/derive_db_execute/src/lib.rs b/derive/derive_db_execute/src/lib.rs index d60692dc..ca914017 100644 --- a/derive/derive_db_execute/src/lib.rs +++ b/derive/derive_db_execute/src/lib.rs @@ -157,7 +157,7 @@ fn build_create_exec( use crate::schema::{schema}::dsl::*; let msg = self; crate::q!({query}).get_result(conn).map_err(|e| {{ - log::error!("{{:?}}", e); + common::log::error!("{{:?}}", e); crate::DatabaseError::GenericFailure( crate::OperationError::Create, crate::ResourceKind::{resource}, @@ -192,7 +192,7 @@ fn build_find_exec( use crate::schema::{schema}::dsl::*; let msg = self; crate::q!({query}).first(conn).map_err(|e| {{ - log::error!("{{:?}}", e); + common::log::error!("{{:?}}", e); crate::DatabaseError::GenericFailure( crate::OperationError::LoadSingle, crate::ResourceKind::{resource}, @@ -226,7 +226,7 @@ fn build_load_exec( use crate::schema::{schema}::dsl::*; let msg = self; crate::q!({query}).load(conn).map_err(|e| {{ - log::error!("{{:?}}", e); + common::log::error!("{{:?}}", e); crate::DatabaseError::GenericFailure( crate::OperationError::LoadCollection, crate::ResourceKind::{resource}, @@ -260,7 +260,7 @@ fn build_update_exec( use crate::schema::{schema}::dsl::*; let msg = self; crate::q!({query}).get_result(conn).map_err(|e| {{ - log::error!("{{:?}}", e); + common::log::error!("{{:?}}", e); crate::DatabaseError::GenericFailure( crate::OperationError::Update, crate::ResourceKind::{resource}, @@ -294,7 +294,7 @@ fn build_destroy_exec( use crate::schema::{schema}::dsl::*; let msg = self; crate::q!({query}).execute(conn).map_err(|e| {{ - log::error!("{{:?}}", e); + common::log::error!("{{:?}}", e); crate::DatabaseError::GenericFailure( crate::OperationError::Delete, crate::ResourceKind::{resource}, diff --git a/shared/common/Cargo.toml b/shared/common/Cargo.toml index 3e03e04f..325e2679 100644 --- a/shared/common/Cargo.toml +++ b/shared/common/Cargo.toml @@ -20,4 +20,8 @@ actix_derive = { version = "*" } serde = { version = "*" } serde_derive = { version = "*" } +log = "0.4" +pretty_env_logger = "0.4" +env_logger = "0.7" + reexport-proc-macro = { version = "*" } diff --git a/shared/common/src/lib.rs b/shared/common/src/lib.rs index 4eeb9901..70564c77 100644 --- a/shared/common/src/lib.rs +++ b/shared/common/src/lib.rs @@ -1,7 +1,10 @@ #[macro_use] extern crate reexport_proc_macro; -pub use {actix_cors, actix_rt, actix_service, actix_web, actix_web_actors, serde}; +pub use { + actix_cors, actix_rt, actix_service, actix_web, actix_web_actors, env_logger, log, + pretty_env_logger, serde, +}; reexport_proc_macro!(actix_derive); reexport_proc_macro!(serde_derive);