enable rust logs

This commit is contained in:
dignifiedquire
2024-05-18 13:07:33 +02:00
parent 37d61e41ca
commit 9fb003563b
3 changed files with 12 additions and 1 deletions

1
Cargo.lock generated
View File

@@ -1426,6 +1426,7 @@ dependencies = [
"tokio-tar",
"tokio-util",
"toml",
"tracing-subscriber",
"url",
"uuid",
]

View File

@@ -104,6 +104,7 @@ tokio-util = "0.7.9"
toml = "0.8"
url = "2"
uuid = { version = "1", features = ["serde", "v4"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Pin OpenSSL to 3.1 releases.
# OpenSSL 3.2 has a regression tracked at <https://github.com/openssl/openssl/issues/23376>
@@ -113,6 +114,7 @@ uuid = { version = "1", features = ["serde", "v4"] }
# 3.1 branch will be supported until 2025-03-14.
openssl-src = "~300.1"
[dev-dependencies]
ansi_term = "0.12.0"
anyhow = { version = "1", features = ["backtrace"] } # Enable `backtrace` feature in tests.
@@ -181,4 +183,4 @@ vendored = [
"async-native-tls/vendored",
"rusqlite/bundled-sqlcipher-vendored-openssl",
"reqwest/native-tls-vendored"
]
]

View File

@@ -13,6 +13,7 @@ use async_channel::{self as channel, Receiver, Sender};
use pgp::SignedPublicKey;
use ratelimit::Ratelimit;
use tokio::sync::{Mutex, Notify, OnceCell, RwLock};
use tracing_subscriber::{prelude::*, EnvFilter};
use crate::aheader::EncryptPreference;
use crate::chat::{get_chat_cnt, ChatId, ProtectionStatus};
@@ -337,6 +338,13 @@ impl Context {
events: Events,
stock_strings: StockStrings,
) -> Result<Context> {
// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_writer(std::io::stderr))
.with(EnvFilter::from_default_env())
.try_init()
.ok();
let context =
Self::new_closed(dbfile, id, events, stock_strings, Default::default()).await?;