Add tracing (#1942)

This commit is contained in:
Riley 2021-11-23 06:16:47 -06:00 committed by GitHub
parent 88c7b95d03
commit 3fea5645f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 150 additions and 85 deletions

122
Cargo.lock generated
View File

@ -311,6 +311,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.45" version = "1.0.45"
@ -365,17 +374,6 @@ dependencies = [
"quick-xml", "quick-xml",
] ]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "0.1.7" version = "0.1.7"
@ -1104,19 +1102,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
[[package]]
name = "env_logger"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]] [[package]]
name = "event-listener" name = "event-listener"
version = "2.5.1" version = "2.5.1"
@ -1557,12 +1542,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.15" version = "0.14.15"
@ -1769,7 +1748,6 @@ dependencies = [
"lemmy_db_views_moderator", "lemmy_db_views_moderator",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
"log",
"openssl", "openssl",
"rand 0.8.4", "rand 0.8.4",
"reqwest", "reqwest",
@ -1796,7 +1774,6 @@ dependencies = [
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_db_views_moderator", "lemmy_db_views_moderator",
"lemmy_utils", "lemmy_utils",
"log",
"serde", "serde",
"serde_json", "serde_json",
"url", "url",
@ -1830,7 +1807,6 @@ dependencies = [
"lemmy_db_views_moderator", "lemmy_db_views_moderator",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
"log",
"openssl", "openssl",
"rand 0.8.4", "rand 0.8.4",
"reqwest", "reqwest",
@ -1841,6 +1817,7 @@ dependencies = [
"strum_macros", "strum_macros",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
"url", "url",
"uuid", "uuid",
"webmention", "webmention",
@ -1874,7 +1851,6 @@ dependencies = [
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
"log",
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"rand 0.8.4", "rand 0.8.4",
@ -1888,6 +1864,7 @@ dependencies = [
"strum_macros", "strum_macros",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
"url", "url",
"uuid", "uuid",
] ]
@ -1908,13 +1885,13 @@ dependencies = [
"http-signature-normalization-reqwest", "http-signature-normalization-reqwest",
"lemmy_apub_lib_derive", "lemmy_apub_lib_derive",
"lemmy_utils", "lemmy_utils",
"log",
"once_cell", "once_cell",
"openssl", "openssl",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
"tracing",
"url", "url",
] ]
@ -1939,7 +1916,6 @@ dependencies = [
"diesel_migrations", "diesel_migrations",
"lemmy_apub_lib", "lemmy_apub_lib",
"lemmy_utils", "lemmy_utils",
"log",
"once_cell", "once_cell",
"regex", "regex",
"serde", "serde",
@ -1957,9 +1933,9 @@ version = "0.14.1"
dependencies = [ dependencies = [
"diesel", "diesel",
"lemmy_db_schema", "lemmy_db_schema",
"log",
"serde", "serde",
"serial_test", "serial_test",
"tracing",
"url", "url",
] ]
@ -2000,7 +1976,6 @@ dependencies = [
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
"log",
"once_cell", "once_cell",
"rss", "rss",
"serde", "serde",
@ -2024,7 +1999,6 @@ dependencies = [
"diesel", "diesel",
"diesel_migrations", "diesel_migrations",
"doku", "doku",
"env_logger",
"http-signature-normalization-actix", "http-signature-normalization-actix",
"lemmy_api", "lemmy_api",
"lemmy_api_common", "lemmy_api_common",
@ -2038,13 +2012,17 @@ dependencies = [
"lemmy_routes", "lemmy_routes",
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
"log",
"openssl", "openssl",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"strum", "strum",
"tokio", "tokio",
"tracing",
"tracing-actix-web",
"tracing-error",
"tracing-log",
"tracing-subscriber",
"url", "url",
] ]
@ -2065,7 +2043,6 @@ dependencies = [
"itertools", "itertools",
"jsonwebtoken", "jsonwebtoken",
"lettre", "lettre",
"log",
"once_cell", "once_cell",
"openssl", "openssl",
"percent-encoding", "percent-encoding",
@ -2079,6 +2056,8 @@ dependencies = [
"strum_macros", "strum_macros",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing",
"tracing-error",
"url", "url",
"uuid", "uuid",
"webpage", "webpage",
@ -2100,7 +2079,6 @@ dependencies = [
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor", "lemmy_db_views_actor",
"lemmy_utils", "lemmy_utils",
"log",
"rand 0.8.4", "rand 0.8.4",
"reqwest", "reqwest",
"serde", "serde",
@ -2108,6 +2086,7 @@ dependencies = [
"strum", "strum",
"strum_macros", "strum_macros",
"tokio", "tokio",
"tracing",
] ]
[[package]] [[package]]
@ -2257,6 +2236,15 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]] [[package]]
name = "matches" name = "matches"
version = "0.1.9" version = "0.1.9"
@ -3102,6 +3090,15 @@ dependencies = [
"regex-syntax", "regex-syntax",
] ]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.25" version = "0.6.25"
@ -3998,6 +3995,19 @@ dependencies = [
"tracing-core", "tracing-core",
] ]
[[package]]
name = "tracing-actix-web"
version = "0.5.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cac34827e06f78b69523b2fbe5b2dd4dfc75940b2ea5ba37e4fa2a25d4a0edf"
dependencies = [
"actix-web",
"pin-project",
"tracing",
"tracing-futures",
"uuid",
]
[[package]] [[package]]
name = "tracing-attributes" name = "tracing-attributes"
version = "0.1.18" version = "0.1.18"
@ -4039,16 +4049,34 @@ dependencies = [
] ]
[[package]] [[package]]
name = "tracing-subscriber" name = "tracing-log"
version = "0.3.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80a4ddde70311d8da398062ecf6fc2c309337de6b0f77d6c27aff8d53f6fca52" checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
dependencies = [ dependencies = [
"sharded-slab", "lazy_static",
"thread_local", "log",
"tracing-core", "tracing-core",
] ]
[[package]]
name = "tracing-subscriber"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507ec620f809cdf07cccb5bc57b13069a88031b795efd4079b1c71b66c1613d"
dependencies = [
"ansi_term",
"lazy_static",
"matchers",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.3" version = "0.2.3"

View File

@ -49,8 +49,11 @@ chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
actix = "0.12.0" actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["rustls"] } actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["rustls"] }
log = "0.4.14" tracing = "0.1.29"
env_logger = "0.9.0" tracing-actix-web = "0.5.0-beta.2"
tracing-error = "0.2.0"
tracing-log = "0.1.2"
tracing-subscriber = { version = "0.3.2", features = ["env-filter"] }
strum = "0.21.0" strum = "0.21.0"
url = { version = "2.2.2", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
openssl = "0.10.36" openssl = "0.10.36"

View File

@ -31,7 +31,6 @@ actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false } actix-web = { version = "4.0.0-beta.9", default-features = false }
actix-rt = { version = "2.2.0", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "3.0.0-beta.8", default-features = false } awc = { version = "3.0.0-beta.8", default-features = false }
log = "0.4.14"
rand = "0.8.4" rand = "0.8.4"
strum = "0.21.0" strum = "0.21.0"
strum_macros = "0.21.1" strum_macros = "0.21.1"

View File

@ -19,7 +19,6 @@ lemmy_db_views_actor = { version = "=0.14.1", path = "../db_views_actor" }
lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" }
lemmy_utils = { version = "=0.14.1", path = "../utils" } lemmy_utils = { version = "=0.14.1", path = "../utils" }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
log = "0.4.14"
diesel = "1.4.8" diesel = "1.4.8"
actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["cookies"] } actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["cookies"] }
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }

View File

@ -26,7 +26,7 @@ actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false } actix-web = { version = "4.0.0-beta.9", default-features = false }
actix-rt = { version = "2.2.0", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "3.0.0-beta.8", default-features = false } awc = { version = "3.0.0-beta.8", default-features = false }
log = "0.4.14" tracing = "0.1.29"
rand = "0.8.4" rand = "0.8.4"
strum = "0.21.0" strum = "0.21.0"
strum_macros = "0.21.1" strum_macros = "0.21.1"

View File

@ -32,7 +32,7 @@ use lemmy_utils::{
LemmyError, LemmyError,
}; };
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
use log::warn; use tracing::warn;
use url::Url; use url::Url;
use webmention::{Webmention, WebmentionError}; use webmention::{Webmention, WebmentionError};

View File

@ -17,7 +17,7 @@ use lemmy_db_views_actor::{
}; };
use lemmy_utils::{version, ApiError, ConnectionId, LemmyError}; use lemmy_utils::{version, ApiError, ConnectionId, LemmyError};
use lemmy_websocket::{messages::GetUsersOnline, LemmyContext}; use lemmy_websocket::{messages::GetUsersOnline, LemmyContext};
use log::info; use tracing::info;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl PerformCrud for GetSite { impl PerformCrud for GetSite {

View File

@ -31,7 +31,7 @@ actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false } actix-web = { version = "4.0.0-beta.9", default-features = false }
actix-rt = { version = "2.2.0", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "3.0.0-beta.8", default-features = false } awc = { version = "3.0.0-beta.8", default-features = false }
log = "0.4.14" tracing = "0.1.29"
rand = "0.8.4" rand = "0.8.4"
strum = "0.21.0" strum = "0.21.0"
strum_macros = "0.21.1" strum_macros = "0.21.1"

View File

@ -21,8 +21,8 @@ use lemmy_db_views_actor::{
}; };
use lemmy_utils::{settings::structs::Settings, LemmyError}; use lemmy_utils::{settings::structs::Settings, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::info;
use serde::Serialize; use serde::Serialize;
use tracing::info;
use url::{ParseError, Url}; use url::{ParseError, Url};
use uuid::Uuid; use uuid::Uuid;

View File

@ -11,8 +11,8 @@ use lemmy_utils::{
LemmyError, LemmyError,
}; };
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::debug;
use url::Url; use url::Url;
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]

View File

@ -27,8 +27,8 @@ use lemmy_apub_lib::{object_id::ObjectId, traits::ApubObject};
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::info;
use serde::Deserialize; use serde::Deserialize;
use tracing::info;
#[derive(Deserialize)] #[derive(Deserialize)]
pub(crate) struct CommunityQuery { pub(crate) struct CommunityQuery {

View File

@ -27,9 +27,9 @@ use lemmy_apub_lib::{
use lemmy_db_schema::source::activity::Activity; use lemmy_db_schema::source::activity::Activity;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::info;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{fmt::Debug, io::Read}; use std::{fmt::Debug, io::Read};
use tracing::info;
use url::Url; use url::Url;
mod comment; mod comment;

View File

@ -17,8 +17,8 @@ use lemmy_apub_lib::traits::ApubObject;
use lemmy_db_schema::source::person::Person; use lemmy_db_schema::source::person::Person;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::info;
use serde::Deserialize; use serde::Deserialize;
use tracing::info;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct PersonQuery { pub struct PersonQuery {

View File

@ -25,8 +25,8 @@ use lemmy_utils::{
LemmyError, LemmyError,
}; };
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use log::debug;
use std::ops::Deref; use std::ops::Deref;
use tracing::debug;
use url::Url; use url::Url;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View File

@ -17,7 +17,7 @@ url = { version = "2.2.2", features = ["serde"] }
serde_json = { version = "1.0.68", features = ["preserve_order"] } serde_json = { version = "1.0.68", features = ["preserve_order"] }
anyhow = "1.0.44" anyhow = "1.0.44"
reqwest = { version = "0.11.4", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
log = "0.4.14" tracing = "0.1.29"
base64 = "0.13.0" base64 = "0.13.0"
openssl = "0.10.36" openssl = "0.10.36"
once_cell = "1.8.0" once_cell = "1.8.0"

View File

@ -10,10 +10,10 @@ use background_jobs::{
WorkerConfig, WorkerConfig,
}; };
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use log::{info, warn};
use reqwest::Client; use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{env, fmt::Debug, future::Future, pin::Pin}; use std::{env, fmt::Debug, future::Future, pin::Pin};
use tracing::{info, warn};
use url::Url; use url::Url;
pub async fn send_activity( pub async fn send_activity(

View File

@ -7,7 +7,6 @@ use lemmy_utils::{
settings::structs::Settings, settings::structs::Settings,
LemmyError, LemmyError,
}; };
use log::info;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reqwest::{Client, StatusCode}; use reqwest::{Client, StatusCode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -16,6 +15,7 @@ use std::{
marker::PhantomData, marker::PhantomData,
time::Duration, time::Duration,
}; };
use tracing::info;
use url::Url; use url::Url;
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object /// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object

View File

@ -5,7 +5,6 @@ use http::{header::HeaderName, HeaderMap, HeaderValue};
use http_signature_normalization_actix::Config as ConfigActix; use http_signature_normalization_actix::Config as ConfigActix;
use http_signature_normalization_reqwest::prelude::{Config, SignExt}; use http_signature_normalization_reqwest::prelude::{Config, SignExt};
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use log::debug;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use openssl::{ use openssl::{
hash::MessageDigest, hash::MessageDigest,
@ -16,6 +15,7 @@ use reqwest::{Client, Response};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::str::FromStr; use std::str::FromStr;
use tracing::debug;
use url::Url; use url::Url;
static CONFIG2: Lazy<ConfigActix> = Lazy::new(ConfigActix::new); static CONFIG2: Lazy<ConfigActix> = Lazy::new(ConfigActix::new);

View File

@ -18,7 +18,6 @@ diesel_migrations = "1.4.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
serde_json = { version = "1.0.68", features = ["preserve_order"] } serde_json = { version = "1.0.68", features = ["preserve_order"] }
log = "0.4.14"
url = { version = "2.2.2", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
diesel-derive-newtype = "0.1.2" diesel-derive-newtype = "0.1.2"
regex = "1.5.4" regex = "1.5.4"

View File

@ -14,7 +14,7 @@ doctest = false
lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
log = "0.4.14" tracing = "0.1.29"
url = "2.2.2" url = "2.2.2"
[dev-dependencies] [dev-dependencies]

View File

@ -28,8 +28,8 @@ use lemmy_db_schema::{
ListingType, ListingType,
SortType, SortType,
}; };
use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::debug;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct PostView { pub struct PostView {

View File

@ -9,8 +9,8 @@ use lemmy_db_schema::{
}, },
traits::{MaybeOptional, ToSafe, ViewToVec}, traits::{MaybeOptional, ToSafe, ViewToVec},
}; };
use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::debug;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct PrivateMessageView { pub struct PrivateMessageView {

View File

@ -24,7 +24,6 @@ actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["r
actix-web-actors = { version = "4.0.0-beta.7", default-features = false } actix-web-actors = { version = "4.0.0-beta.7", default-features = false }
actix-http = "3.0.0-beta.10" actix-http = "3.0.0-beta.10"
sha2 = "0.9.8" sha2 = "0.9.8"
log = "0.4.14"
anyhow = "1.0.44" anyhow = "1.0.44"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
rss = "1.10.0" rss = "1.10.0"

View File

@ -16,7 +16,8 @@ doctest = false
regex = "1.5.4" regex = "1.5.4"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
lettre = "0.10.0-rc.3" lettre = "0.10.0-rc.3"
log = "0.4.14" tracing = "0.1.29"
tracing-error = "0.2.0"
itertools = "0.10.1" itertools = "0.10.1"
rand = "0.8.4" rand = "0.8.4"
percent-encoding = "2.1.0" percent-encoding = "2.1.0"

View File

@ -16,9 +16,10 @@ pub mod utils;
pub mod version; pub mod version;
use http::StatusCode; use http::StatusCode;
use log::warn;
use std::{fmt, fmt::Display}; use std::{fmt, fmt::Display};
use thiserror::Error; use thiserror::Error;
use tracing::warn;
use tracing_error::SpanTrace;
pub type ConnectionId = usize; pub type ConnectionId = usize;
@ -66,6 +67,7 @@ impl ApiError {
#[derive(Debug)] #[derive(Debug)]
pub struct LemmyError { pub struct LemmyError {
pub inner: anyhow::Error, pub inner: anyhow::Error,
pub context: SpanTrace,
} }
impl<T> From<T> for LemmyError impl<T> From<T> for LemmyError
@ -73,13 +75,17 @@ where
T: Into<anyhow::Error>, T: Into<anyhow::Error>,
{ {
fn from(t: T) -> Self { fn from(t: T) -> Self {
LemmyError { inner: t.into() } LemmyError {
inner: t.into(),
context: SpanTrace::capture(),
}
} }
} }
impl Display for LemmyError { impl Display for LemmyError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.inner.fmt(f) self.inner.fmt(f)?;
self.context.fmt(f)
} }
} }

View File

@ -1,7 +1,7 @@
use crate::{ApiError, IpAddr, LemmyError}; use crate::{ApiError, IpAddr, LemmyError};
use log::debug;
use std::{collections::HashMap, time::SystemTime}; use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use tracing::debug;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct RateLimitBucket { struct RateLimitBucket {

View File

@ -1,11 +1,11 @@
use crate::{settings::structs::Settings, version::VERSION, LemmyError}; use crate::{settings::structs::Settings, version::VERSION, LemmyError};
use anyhow::anyhow; use anyhow::anyhow;
use log::error;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use reqwest::Client; use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::future::Future; use std::future::Future;
use thiserror::Error; use thiserror::Error;
use tracing::error;
use url::Url; use url::Url;
use webpage::HTML; use webpage::HTML;

View File

@ -19,7 +19,7 @@ lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.1", path = "../db_views" } lemmy_db_views = { version = "=0.14.1", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.1", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.1", path = "../db_views_actor" }
reqwest = { version = "0.11.4", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
log = "0.4.14" tracing = "0.1.29"
rand = "0.8.4" rand = "0.8.4"
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
serde_json = { version = "1.0.68", features = ["preserve_order"] } serde_json = { version = "1.0.68", features = ["preserve_order"] }

View File

@ -6,9 +6,9 @@ use crate::{
use actix::{Actor, Context, Handler, ResponseFuture}; use actix::{Actor, Context, Handler, ResponseFuture};
use lemmy_db_schema::naive_now; use lemmy_db_schema::naive_now;
use lemmy_utils::ConnectionId; use lemmy_utils::ConnectionId;
use log::{error, info};
use rand::Rng; use rand::Rng;
use serde::Serialize; use serde::Serialize;
use tracing::{error, info};
/// Make actor from `ChatServer` /// Make actor from `ChatServer`
impl Actor for ChatServer { impl Actor for ChatServer {

View File

@ -7,8 +7,8 @@ use actix::prelude::*;
use actix_web::*; use actix_web::*;
use actix_web_actors::ws; use actix_web_actors::ws;
use lemmy_utils::{utils::get_ip, ConnectionId, IpAddr}; use lemmy_utils::{utils::get_ip, ConnectionId, IpAddr};
use log::{debug, error, info};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use tracing::{debug, error, info};
/// How often heartbeat pings are sent /// How often heartbeat pings are sent
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5); const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);

View File

@ -34,7 +34,7 @@ use lemmy_utils::{
ConnectionId, ConnectionId,
LemmyError, LemmyError,
}; };
use log::error; use tracing::error;
pub async fn send_post_ws_message<OP: ToString + Send + OperationType + 'static>( pub async fn send_post_ws_message<OP: ToString + Send + OperationType + 'static>(
post_id: PostId, post_id: PostId,

View File

@ -22,7 +22,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_utils::{apub::generate_actor_keypair, LemmyError}; use lemmy_utils::{apub::generate_actor_keypair, LemmyError};
use log::info; use tracing::info;
pub fn run_advanced_migrations( pub fn run_advanced_migrations(
conn: &PgConnection, conn: &PgConnection,

View File

@ -2,3 +2,27 @@
pub mod api_routes; pub mod api_routes;
pub mod code_migrations; pub mod code_migrations;
pub mod scheduled_tasks; pub mod scheduled_tasks;
use lemmy_utils::LemmyError;
use tracing::subscriber::set_global_default;
use tracing_error::ErrorLayer;
use tracing_log::LogTracer;
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter, Registry};
pub fn init_tracing() -> Result<(), LemmyError> {
LogTracer::init()?;
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
let format_layer = tracing_subscriber::fmt::layer()
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
.pretty();
let subscriber = Registry::default()
.with(env_filter)
.with(format_layer)
.with(ErrorLayer::default());
set_global_default(subscriber)?;
Ok(())
}

View File

@ -14,7 +14,12 @@ use lemmy_api_crud::match_websocket_operation_crud;
use lemmy_apub_lib::activity_queue::create_activity_queue; use lemmy_apub_lib::activity_queue::create_activity_queue;
use lemmy_db_schema::{get_database_url_from_env, source::secret::Secret}; use lemmy_db_schema::{get_database_url_from_env, source::secret::Secret};
use lemmy_routes::{feeds, images, nodeinfo, webfinger}; use lemmy_routes::{feeds, images, nodeinfo, webfinger};
use lemmy_server::{api_routes, code_migrations::run_advanced_migrations, scheduled_tasks}; use lemmy_server::{
api_routes,
code_migrations::run_advanced_migrations,
init_tracing,
scheduled_tasks,
};
use lemmy_utils::{ use lemmy_utils::{
rate_limit::{rate_limiter::RateLimiter, RateLimit}, rate_limit::{rate_limiter::RateLimiter, RateLimit},
request::build_user_agent, request::build_user_agent,
@ -25,6 +30,7 @@ use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
use reqwest::Client; use reqwest::Client;
use std::{env, sync::Arc, thread}; use std::{env, sync::Arc, thread};
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tracing_actix_web::TracingLogger;
embed_migrations!(); embed_migrations!();
@ -40,7 +46,8 @@ async fn main() -> Result<(), LemmyError> {
return Ok(()); return Ok(());
} }
env_logger::init(); init_tracing()?;
let settings = Settings::init().expect("Couldn't initialize settings."); let settings = Settings::init().expect("Couldn't initialize settings.");
// Set up the r2d2 connection pool // Set up the r2d2 connection pool
@ -114,7 +121,7 @@ async fn main() -> Result<(), LemmyError> {
); );
let rate_limiter = rate_limiter.clone(); let rate_limiter = rate_limiter.clone();
App::new() App::new()
.wrap(middleware::Logger::default()) .wrap(TracingLogger::default())
.app_data(Data::new(context)) .app_data(Data::new(context))
// The routes // The routes
.configure(|cfg| api_routes::config(cfg, &rate_limiter)) .configure(|cfg| api_routes::config(cfg, &rate_limiter))

View File

@ -4,8 +4,8 @@ use clokwerk::{Scheduler, TimeUnits};
use diesel::{sql_query, PgConnection, RunQueryDsl}; use diesel::{sql_query, PgConnection, RunQueryDsl};
use lemmy_db_schema::{source::activity::Activity, DbPool}; use lemmy_db_schema::{source::activity::Activity, DbPool};
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use log::info;
use std::{thread, time::Duration}; use std::{thread, time::Duration};
use tracing::info;
/// Schedules various cleanup tasks for lemmy in a background thread /// Schedules various cleanup tasks for lemmy in a background thread
pub fn setup(pool: DbPool) -> Result<(), LemmyError> { pub fn setup(pool: DbPool) -> Result<(), LemmyError> {