Merge pull request 'Initialize tracing subscriber' (#875) from init-tracing into main

Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/875
This commit is contained in:
KitaitiMakoto 2021-01-11 00:24:54 +00:00
commit 76ec0d2b13
10 changed files with 107 additions and 25 deletions

81
Cargo.lock generated
View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -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 {

View File

@ -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 ""

View File

@ -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,

View File

@ -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,8 @@ use std::path::Path;
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")
@ -83,8 +85,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 +178,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![

View File

@ -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);

View File

@ -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};

View File

@ -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;