From b93ebedaf3bc5549daf7607051d14c639368a3f6 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 9 Jan 2021 18:41:47 +0900 Subject: [PATCH 1/5] Revert "Initialize Rocket early to initialize logger early" This reverts commit 30093d3a9f80a31a4d656f984aa155adf082e521. --- src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 23e24799..845bafac 100755 --- a/src/main.rs +++ b/src/main.rs @@ -83,8 +83,6 @@ and https://docs.joinplu.me/installation/init for more info. "#, ) .get_matches(); - // Initialize Rocket early to load its internal logger - let rocket = rocket::custom(CONFIG.rocket.clone().unwrap()); let dbpool = init_pool().expect("main: database pool initialization error"); if IMPORTED_MIGRATIONS .is_pending(&dbpool.get().unwrap()) @@ -178,7 +176,7 @@ Then try to restart Plume warn!("Please refer to the documentation to see how to configure it."); } - let rocket = rocket + let rocket = rocket::custom(CONFIG.rocket.clone().unwrap()) .mount( "/", routes![ From 894c4fee2c91423365acaeb975f5f18f1e3fd40a Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 10 Jan 2021 18:22:38 +0900 Subject: [PATCH 2/5] Add tracing-subscriber to dependencies --- Cargo.lock | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 82 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 46e6bef3..4a1eecfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,6 +144,14 @@ dependencies = [ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "array_tool" version = "1.0.3" @@ -1968,6 +1976,14 @@ dependencies = [ "tendril 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "matches" version = "0.1.8" @@ -2599,6 +2615,7 @@ dependencies = [ "serde_json 1.0.61 (registry+https://github.com/rust-lang/crates.io-index)", "shrinkwraprs 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "tracing 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-subscriber 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "validator 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "validator_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "webfinger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3084,6 +3101,15 @@ dependencies = [ "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex-syntax" version = "0.4.2" @@ -3467,6 +3493,14 @@ dependencies = [ "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sharded-slab" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "shrinkwraprs" version = "0.2.3" @@ -4213,6 +4247,46 @@ dependencies = [ "tracing 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tracing-log" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.118 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "matchers 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.118 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.61 (registry+https://github.com/rust-lang/crates.io-index)", + "sharded-slab 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-log 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-serde 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "traitobject" version = "0.1.0" @@ -4666,6 +4740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aho-corasick 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" "checksum ammonia 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "384d704f242a0a9faf793fff775a0be6ab9aa27edabffa097331d73779142520" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" "checksum array_tool 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271" "checksum arrayvec 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" "checksum ascii_utils 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" @@ -4872,6 +4947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" "checksum markup5ever 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f1af46a727284117e09780d05038b1ce6fc9c76cc6df183c3dae5a8955a25e21" +"checksum matchers 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum md5 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" @@ -4981,6 +5057,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" "checksum regex 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +"checksum regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum regex-syntax 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" "checksum remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" @@ -5017,6 +5094,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_urlencoded 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +"checksum sharded-slab 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" "checksum shrinkwraprs 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "83695fde96cbe9e08f0e4eb96b1b56fdbd44f2098ee27462dda964c7745fddc7" "checksum shrinkwraprs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e63e6744142336dfb606fe2b068afa2e1cca1ee6a5d8377277a92945d81fa331" "checksum signal-hook-registry 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" @@ -5088,6 +5166,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tracing-attributes 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" "checksum tracing-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" "checksum tracing-futures 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +"checksum tracing-log 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +"checksum tracing-serde 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +"checksum tracing-subscriber 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" diff --git a/Cargo.toml b/Cargo.toml index 64a50f03..cf8d5ee2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ validator = "0.8" validator_derive = "0.8" webfinger = "0.4.1" tracing = "0.1.22" +tracing-subscriber = "0.2.15" [[bin]] name = "plume" From 4a4534d6f36151a8d58f5b60917c68e318a33f86 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 11 Jan 2021 08:38:41 +0900 Subject: [PATCH 3/5] Run cargo fmt --- plume-common/src/activity_pub/mod.rs | 2 +- plume-models/src/migrations.rs | 2 +- src/inbox.rs | 2 +- src/main.rs | 2 +- src/routes/errors.rs | 2 +- src/routes/session.rs | 2 +- src/routes/user.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index 423cc4ff..67c7375f 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -1,6 +1,5 @@ use activitypub::{Activity, Link, Object}; use array_tool::vec::Uniq; -use tracing::{debug, warn}; use reqwest::r#async::ClientBuilder; use rocket::{ http::Status, @@ -10,6 +9,7 @@ use rocket::{ }; use serde_json; use tokio::prelude::*; +use tracing::{debug, warn}; use self::sign::Signable; diff --git a/plume-models/src/migrations.rs b/plume-models/src/migrations.rs index f7fd05dc..301ddbfe 100644 --- a/plume-models/src/migrations.rs +++ b/plume-models/src/migrations.rs @@ -1,8 +1,8 @@ use crate::{Connection, Error, Result}; use diesel::connection::{Connection as Conn, SimpleConnection}; -use tracing::info; use migrations_internals::{setup_database, MigrationConnection}; use std::path::Path; +use tracing::info; #[allow(dead_code)] //variants might not be constructed if not required by current migrations enum Action { diff --git a/src/inbox.rs b/src/inbox.rs index ecb6e0e6..059bf632 100644 --- a/src/inbox.rs +++ b/src/inbox.rs @@ -1,4 +1,3 @@ -use tracing::warn; use plume_common::activity_pub::{ inbox::FromId, request::Digest, @@ -11,6 +10,7 @@ use rocket::{data::*, http::Status, response::status, Outcome::*, Request}; use rocket_contrib::json::*; use serde::Deserialize; use std::io::Read; +use tracing::warn; pub fn handle_incoming( rockets: PlumeRocket, diff --git a/src/main.rs b/src/main.rs index 845bafac..e815e906 100755 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,6 @@ extern crate validator_derive; use chrono::Utc; use clap::App; use diesel::r2d2::ConnectionManager; -use tracing::warn; use plume_models::{ db_conn::{DbPool, PragmaForeignKey}, instance::Instance, @@ -28,6 +27,7 @@ use std::path::Path; use std::process::exit; use std::sync::{Arc, Mutex}; use std::time::Duration; +use tracing::warn; init_i18n!( "plume", af, ar, bg, ca, cs, cy, da, de, el, en, eo, es, fa, fi, fr, gl, he, hi, hr, hu, it, diff --git a/src/routes/errors.rs b/src/routes/errors.rs index 8549da80..7632f347 100644 --- a/src/routes/errors.rs +++ b/src/routes/errors.rs @@ -1,10 +1,10 @@ use crate::template_utils::{IntoContext, Ructe}; -use tracing::warn; use plume_models::{Error, PlumeRocket}; use rocket::{ response::{self, Responder}, Request, }; +use tracing::warn; #[derive(Debug)] pub struct ErrorPage(Error); diff --git a/src/routes/session.rs b/src/routes/session.rs index 4d1dfe73..86955f9a 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -1,6 +1,5 @@ use crate::routes::RespondOrRedirect; use lettre::Transport; -use tracing::warn; use rocket::http::ext::IntoOwned; use rocket::{ http::{uri::Uri, Cookie, Cookies, SameSite}, @@ -14,6 +13,7 @@ use std::{ sync::{Arc, Mutex}, time::Instant, }; +use tracing::warn; use validator::{Validate, ValidationError, ValidationErrors}; use crate::mail::{build_mail, Mailer}; diff --git a/src/routes/user.rs b/src/routes/user.rs index 5164442e..90baaf94 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -3,7 +3,6 @@ use activitypub::{ collection::{OrderedCollection, OrderedCollectionPage}, }; use diesel::SaveChangesDsl; -use tracing::{info, warn}; use rocket::{ http::{ContentType, Cookies}, request::LenientForm, @@ -12,6 +11,7 @@ use rocket::{ use rocket_i18n::I18n; use serde_json; use std::{borrow::Cow, collections::HashMap}; +use tracing::{info, warn}; use validator::{Validate, ValidationError, ValidationErrors}; use crate::inbox; From b9b9af6c442a376ce1ee0d824351d14092824e2e Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 11 Jan 2021 09:15:34 +0900 Subject: [PATCH 4/5] Initialize tracing subscriber --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index e815e906..08282fc2 100755 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ use std::process::exit; use std::sync::{Arc, Mutex}; use std::time::Duration; use tracing::warn; +use tracing_subscriber; init_i18n!( "plume", af, ar, bg, ca, cs, cy, da, de, el, en, eo, es, fa, fi, fr, gl, he, hi, hr, hu, it, @@ -69,6 +70,7 @@ fn main() { Err(ref e) if e.not_found() => eprintln!("no .env was found"), e => e.map(|_| ()).unwrap(), } + tracing_subscriber::fmt::init(); App::new("Plume") .bin_name("plume") From 4d547082e06484400072853009e63392651f916b Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 11 Jan 2021 09:15:45 +0900 Subject: [PATCH 5/5] Update pot --- po/plume/plume.pot | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/po/plume/plume.pot b/po/plume/plume.pot index 7e5f8059..8350a2b7 100644 --- a/po/plume/plume.pot +++ b/po/plume/plume.pot @@ -220,63 +220,63 @@ msgstr "" msgid "To reshare a post, you need to be logged in" msgstr "" -# src/routes/session.rs:87 +# src/routes/session.rs:88 msgid "You are now connected." msgstr "" -# src/routes/session.rs:108 +# src/routes/session.rs:109 msgid "You are now logged off." msgstr "" -# src/routes/session.rs:153 +# src/routes/session.rs:154 msgid "Password reset" msgstr "" -# src/routes/session.rs:154 +# src/routes/session.rs:155 msgid "Here is the link to reset your password: {0}" msgstr "" -# src/routes/session.rs:216 +# src/routes/session.rs:217 msgid "Your password was successfully reset." msgstr "" -# src/routes/user.rs:141 +# src/routes/user.rs:142 msgid "To access your dashboard, you need to be logged in" msgstr "" -# src/routes/user.rs:163 +# src/routes/user.rs:164 msgid "You are no longer following {}." msgstr "" -# src/routes/user.rs:180 +# src/routes/user.rs:181 msgid "You are now following {}." msgstr "" -# src/routes/user.rs:260 +# src/routes/user.rs:261 msgid "To subscribe to someone, you need to be logged in" msgstr "" -# src/routes/user.rs:364 +# src/routes/user.rs:365 msgid "To edit your profile, you need to be logged in" msgstr "" -# src/routes/user.rs:409 +# src/routes/user.rs:410 msgid "Your profile has been updated." msgstr "" -# src/routes/user.rs:436 +# src/routes/user.rs:437 msgid "Your account has been deleted." msgstr "" -# src/routes/user.rs:442 +# src/routes/user.rs:443 msgid "You can't delete someone else's account." msgstr "" -# src/routes/user.rs:526 +# src/routes/user.rs:527 msgid "Registrations are closed on this instance." msgstr "" -# src/routes/user.rs:549 +# src/routes/user.rs:550 msgid "Your account has been created. Now you just need to log in, before you can use it." msgstr ""