"memchr",
]
+[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "anyhow"
version = "1.0.45"
"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]]
name = "autocfg"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "event-listener"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
-[[package]]
-name = "humantime"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
-
[[package]]
name = "hyper"
version = "0.14.15"
"lemmy_db_views_moderator",
"lemmy_utils",
"lemmy_websocket",
- "log",
"openssl",
"rand 0.8.4",
"reqwest",
"lemmy_db_views_actor",
"lemmy_db_views_moderator",
"lemmy_utils",
- "log",
"serde",
"serde_json",
"url",
"lemmy_db_views_moderator",
"lemmy_utils",
"lemmy_websocket",
- "log",
"openssl",
"rand 0.8.4",
"reqwest",
"strum_macros",
"thiserror",
"tokio",
+ "tracing",
"url",
"uuid",
"webmention",
"lemmy_db_views_actor",
"lemmy_utils",
"lemmy_websocket",
- "log",
"once_cell",
"percent-encoding",
"rand 0.8.4",
"strum_macros",
"thiserror",
"tokio",
+ "tracing",
"url",
"uuid",
]
"http-signature-normalization-reqwest",
"lemmy_apub_lib_derive",
"lemmy_utils",
- "log",
"once_cell",
"openssl",
"reqwest",
"serde",
"serde_json",
"sha2",
+ "tracing",
"url",
]
"diesel_migrations",
"lemmy_apub_lib",
"lemmy_utils",
- "log",
"once_cell",
"regex",
"serde",
dependencies = [
"diesel",
"lemmy_db_schema",
- "log",
"serde",
"serial_test",
+ "tracing",
"url",
]
"lemmy_db_views_actor",
"lemmy_utils",
"lemmy_websocket",
- "log",
"once_cell",
"rss",
"serde",
"diesel",
"diesel_migrations",
"doku",
- "env_logger",
"http-signature-normalization-actix",
"lemmy_api",
"lemmy_api_common",
"lemmy_routes",
"lemmy_utils",
"lemmy_websocket",
- "log",
"openssl",
"reqwest",
"serde",
"serde_json",
"strum",
"tokio",
+ "tracing",
+ "tracing-actix-web",
+ "tracing-error",
+ "tracing-log",
+ "tracing-subscriber",
"url",
]
"itertools",
"jsonwebtoken",
"lettre",
- "log",
"once_cell",
"openssl",
"percent-encoding",
"strum_macros",
"thiserror",
"tokio",
+ "tracing",
+ "tracing-error",
"url",
"uuid",
"webpage",
"lemmy_db_views",
"lemmy_db_views_actor",
"lemmy_utils",
- "log",
"rand 0.8.4",
"reqwest",
"serde",
"strum",
"strum_macros",
"tokio",
+ "tracing",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "matches"
version = "0.1.9"
"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]]
name = "regex-syntax"
version = "0.6.25"
"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]]
name = "tracing-attributes"
version = "0.1.18"
"tracing",
]
+[[package]]
+name = "tracing-log"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
+dependencies = [
+ "lazy_static",
+ "log",
+ "tracing-core",
+]
+
[[package]]
name = "tracing-subscriber"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "80a4ddde70311d8da398062ecf6fc2c309337de6b0f77d6c27aff8d53f6fca52"
+checksum = "7507ec620f809cdf07cccb5bc57b13069a88031b795efd4079b1c71b66c1613d"
dependencies = [
+ "ansi_term",
+ "lazy_static",
+ "matchers",
+ "regex",
"sharded-slab",
+ "smallvec",
"thread_local",
+ "tracing",
"tracing-core",
+ "tracing-log",
]
[[package]]
serde = { version = "1.0.130", features = ["derive"] }
actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["rustls"] }
-log = "0.4.14"
-env_logger = "0.9.0"
+tracing = "0.1.29"
+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"
url = { version = "2.2.2", features = ["serde"] }
openssl = "0.10.36"
actix-web = { version = "4.0.0-beta.9", default-features = false }
actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "3.0.0-beta.8", default-features = false }
-log = "0.4.14"
rand = "0.8.4"
strum = "0.21.0"
strum_macros = "0.21.1"
lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" }
lemmy_utils = { version = "=0.14.1", path = "../utils" }
serde = { version = "1.0.130", features = ["derive"] }
-log = "0.4.14"
diesel = "1.4.8"
actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["cookies"] }
chrono = { version = "0.4.19", features = ["serde"] }
actix-web = { version = "4.0.0-beta.9", default-features = false }
actix-rt = { version = "2.2.0", 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"
strum = "0.21.0"
strum_macros = "0.21.1"
LemmyError,
};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
-use log::warn;
+use tracing::warn;
use url::Url;
use webmention::{Webmention, WebmentionError};
};
use lemmy_utils::{version, ApiError, ConnectionId, LemmyError};
use lemmy_websocket::{messages::GetUsersOnline, LemmyContext};
-use log::info;
+use tracing::info;
#[async_trait::async_trait(?Send)]
impl PerformCrud for GetSite {
actix-web = { version = "4.0.0-beta.9", default-features = false }
actix-rt = { version = "2.2.0", 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"
strum = "0.21.0"
strum_macros = "0.21.1"
};
use lemmy_utils::{settings::structs::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
-use log::info;
use serde::Serialize;
+use tracing::info;
use url::{ParseError, Url};
use uuid::Uuid;
LemmyError,
};
use lemmy_websocket::LemmyContext;
-use log::debug;
use serde::{Deserialize, Serialize};
+use tracing::debug;
use url::Url;
#[derive(Serialize, Deserialize, Debug)]
use lemmy_db_schema::source::community::Community;
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
-use log::info;
use serde::Deserialize;
+use tracing::info;
#[derive(Deserialize)]
pub(crate) struct CommunityQuery {
use lemmy_db_schema::source::activity::Activity;
use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext;
-use log::info;
use serde::{Deserialize, Serialize};
use std::{fmt::Debug, io::Read};
+use tracing::info;
use url::Url;
mod comment;
use lemmy_db_schema::source::person::Person;
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
-use log::info;
use serde::Deserialize;
+use tracing::info;
#[derive(Deserialize)]
pub struct PersonQuery {
LemmyError,
};
use lemmy_websocket::LemmyContext;
-use log::debug;
use std::ops::Deref;
+use tracing::debug;
use url::Url;
#[derive(Clone, Debug)]
serde_json = { version = "1.0.68", features = ["preserve_order"] }
anyhow = "1.0.44"
reqwest = { version = "0.11.4", features = ["json"] }
-log = "0.4.14"
+tracing = "0.1.29"
base64 = "0.13.0"
openssl = "0.10.36"
once_cell = "1.8.0"
WorkerConfig,
};
use lemmy_utils::{location_info, LemmyError};
-use log::{info, warn};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::{env, fmt::Debug, future::Future, pin::Pin};
+use tracing::{info, warn};
use url::Url;
pub async fn send_activity(
settings::structs::Settings,
LemmyError,
};
-use log::info;
use once_cell::sync::Lazy;
use reqwest::{Client, StatusCode};
use serde::{Deserialize, Serialize};
marker::PhantomData,
time::Duration,
};
+use tracing::info;
use url::Url;
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object
use http_signature_normalization_actix::Config as ConfigActix;
use http_signature_normalization_reqwest::prelude::{Config, SignExt};
use lemmy_utils::LemmyError;
-use log::debug;
use once_cell::sync::Lazy;
use openssl::{
hash::MessageDigest,
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::str::FromStr;
+use tracing::debug;
use url::Url;
static CONFIG2: Lazy<ConfigActix> = Lazy::new(ConfigActix::new);
chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.130", features = ["derive"] }
serde_json = { version = "1.0.68", features = ["preserve_order"] }
-log = "0.4.14"
url = { version = "2.2.2", features = ["serde"] }
diesel-derive-newtype = "0.1.2"
regex = "1.5.4"
lemmy_db_schema = { version = "=0.14.1", path = "../db_schema" }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.130", features = ["derive"] }
-log = "0.4.14"
+tracing = "0.1.29"
url = "2.2.2"
[dev-dependencies]
ListingType,
SortType,
};
-use log::debug;
use serde::{Deserialize, Serialize};
+use tracing::debug;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct PostView {
},
traits::{MaybeOptional, ToSafe, ViewToVec},
};
-use log::debug;
use serde::{Deserialize, Serialize};
+use tracing::debug;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct PrivateMessageView {
actix-web-actors = { version = "4.0.0-beta.7", default-features = false }
actix-http = "3.0.0-beta.10"
sha2 = "0.9.8"
-log = "0.4.14"
anyhow = "1.0.44"
chrono = { version = "0.4.19", features = ["serde"] }
rss = "1.10.0"
regex = "1.5.4"
chrono = { version = "0.4.19", features = ["serde"] }
lettre = "0.10.0-rc.3"
-log = "0.4.14"
+tracing = "0.1.29"
+tracing-error = "0.2.0"
itertools = "0.10.1"
rand = "0.8.4"
percent-encoding = "2.1.0"
pub mod version;
use http::StatusCode;
-use log::warn;
use std::{fmt, fmt::Display};
use thiserror::Error;
+use tracing::warn;
+use tracing_error::SpanTrace;
pub type ConnectionId = usize;
#[derive(Debug)]
pub struct LemmyError {
pub inner: anyhow::Error,
+ pub context: SpanTrace,
}
impl<T> From<T> for LemmyError
T: Into<anyhow::Error>,
{
fn from(t: T) -> Self {
- LemmyError { inner: t.into() }
+ LemmyError {
+ inner: t.into(),
+ context: SpanTrace::capture(),
+ }
}
}
impl Display for LemmyError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- self.inner.fmt(f)
+ self.inner.fmt(f)?;
+ self.context.fmt(f)
}
}
use crate::{ApiError, IpAddr, LemmyError};
-use log::debug;
use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator;
+use tracing::debug;
#[derive(Debug, Clone)]
struct RateLimitBucket {
use crate::{settings::structs::Settings, version::VERSION, LemmyError};
use anyhow::anyhow;
-use log::error;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::future::Future;
use thiserror::Error;
+use tracing::error;
use url::Url;
use webpage::HTML;
lemmy_db_views = { version = "=0.14.1", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.1", path = "../db_views_actor" }
reqwest = { version = "0.11.4", features = ["json"] }
-log = "0.4.14"
+tracing = "0.1.29"
rand = "0.8.4"
serde = { version = "1.0.130", features = ["derive"] }
serde_json = { version = "1.0.68", features = ["preserve_order"] }
use actix::{Actor, Context, Handler, ResponseFuture};
use lemmy_db_schema::naive_now;
use lemmy_utils::ConnectionId;
-use log::{error, info};
use rand::Rng;
use serde::Serialize;
+use tracing::{error, info};
/// Make actor from `ChatServer`
impl Actor for ChatServer {
use actix_web::*;
use actix_web_actors::ws;
use lemmy_utils::{utils::get_ip, ConnectionId, IpAddr};
-use log::{debug, error, info};
use std::time::{Duration, Instant};
+use tracing::{debug, error, info};
/// How often heartbeat pings are sent
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
ConnectionId,
LemmyError,
};
-use log::error;
+use tracing::error;
pub async fn send_post_ws_message<OP: ToString + Send + OperationType + 'static>(
post_id: PostId,
traits::Crud,
};
use lemmy_utils::{apub::generate_actor_keypair, LemmyError};
-use log::info;
+use tracing::info;
pub fn run_advanced_migrations(
conn: &PgConnection,
pub mod api_routes;
pub mod code_migrations;
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(())
+}
use lemmy_apub_lib::activity_queue::create_activity_queue;
use lemmy_db_schema::{get_database_url_from_env, source::secret::Secret};
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::{
rate_limit::{rate_limiter::RateLimiter, RateLimit},
request::build_user_agent,
use reqwest::Client;
use std::{env, sync::Arc, thread};
use tokio::sync::Mutex;
+use tracing_actix_web::TracingLogger;
embed_migrations!();
return Ok(());
}
- env_logger::init();
+ init_tracing()?;
+
let settings = Settings::init().expect("Couldn't initialize settings.");
// Set up the r2d2 connection pool
);
let rate_limiter = rate_limiter.clone();
App::new()
- .wrap(middleware::Logger::default())
+ .wrap(TracingLogger::default())
.app_data(Data::new(context))
// The routes
.configure(|cfg| api_routes::config(cfg, &rate_limiter))
use diesel::{sql_query, PgConnection, RunQueryDsl};
use lemmy_db_schema::{source::activity::Activity, DbPool};
use lemmy_utils::LemmyError;
-use log::info;
use std::{thread, time::Duration};
+use tracing::info;
/// Schedules various cleanup tasks for lemmy in a background thread
pub fn setup(pool: DbPool) -> Result<(), LemmyError> {