add optional support for tokio-console
This turned out to be quite hairy, mostly because we need to apply the config's log level filter to the actual logs (stdout and, optionally sentry), but do not want to filter out the tokio tracing events needed by the console_subscriber. I hit several edge cases in tracing getting this to work, and we now depend on a git version of tracing with a backported patch :(
This commit is contained in:
parent
341bafb91e
commit
8a5599adf9
8 changed files with 488 additions and 105 deletions
|
@ -331,7 +331,7 @@ pub(crate) async fn change_log_level(
|
|||
match services()
|
||||
.globals
|
||||
.tracing_reload_handle
|
||||
.modify(|filter| *filter = old_filter_layer)
|
||||
.reload(&old_filter_layer)
|
||||
{
|
||||
Ok(()) => {
|
||||
return Ok(RoomMessageEventContent::text_plain(format!(
|
||||
|
@ -360,7 +360,7 @@ pub(crate) async fn change_log_level(
|
|||
match services()
|
||||
.globals
|
||||
.tracing_reload_handle
|
||||
.modify(|filter| *filter = new_filter_layer)
|
||||
.reload(&new_filter_layer)
|
||||
{
|
||||
Ok(()) => {
|
||||
return Ok(RoomMessageEventContent::text_plain("Successfully changed log level"));
|
||||
|
|
|
@ -27,10 +27,9 @@ use ruma::{
|
|||
};
|
||||
use tokio::sync::{broadcast, watch::Receiver, Mutex, RwLock};
|
||||
use tracing::{error, info, trace};
|
||||
use tracing_subscriber::{EnvFilter, Registry};
|
||||
use url::Url;
|
||||
|
||||
use crate::{services, Config, Result};
|
||||
use crate::{services, Config, LogLevelReloadHandles, Result};
|
||||
|
||||
mod client;
|
||||
mod data;
|
||||
|
@ -45,7 +44,7 @@ type SyncHandle = (
|
|||
pub(crate) struct Service<'a> {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
|
||||
pub(crate) tracing_reload_handle: tracing_subscriber::reload::Handle<EnvFilter, Registry>,
|
||||
pub(crate) tracing_reload_handle: LogLevelReloadHandles,
|
||||
pub(crate) config: Config,
|
||||
pub(crate) cidr_range_denylist: Vec<IPAddress>,
|
||||
keypair: Arc<ruma::signatures::Ed25519KeyPair>,
|
||||
|
@ -99,8 +98,7 @@ impl Default for RotationHandler {
|
|||
|
||||
impl Service<'_> {
|
||||
pub(crate) fn load(
|
||||
db: &'static dyn Data, config: &Config,
|
||||
tracing_reload_handle: tracing_subscriber::reload::Handle<EnvFilter, Registry>,
|
||||
db: &'static dyn Data, config: &Config, tracing_reload_handle: LogLevelReloadHandles,
|
||||
) -> Result<Self> {
|
||||
let keypair = db.load_keypair();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
use lru_cache::LruCache;
|
||||
use tokio::sync::{broadcast, Mutex, RwLock};
|
||||
|
||||
use crate::{Config, Result};
|
||||
use crate::{Config, LogLevelReloadHandles, Result};
|
||||
|
||||
pub(crate) mod account_data;
|
||||
pub(crate) mod admin;
|
||||
|
@ -55,11 +55,7 @@ impl Services<'_> {
|
|||
+ sending::Data
|
||||
+ 'static,
|
||||
>(
|
||||
db: &'static D, config: &Config,
|
||||
tracing_reload_handle: tracing_subscriber::reload::Handle<
|
||||
tracing_subscriber::EnvFilter,
|
||||
tracing_subscriber::Registry,
|
||||
>,
|
||||
db: &'static D, config: &Config, tracing_reload_handle: LogLevelReloadHandles,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
appservice: appservice::Service::build(db)?,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue