fix: allow tokio tracing to be enabled

fixes https://github.com/scsibug/nostr-rs-relay/issues/48
This commit is contained in:
Greg Heartsfield 2023-01-14 09:47:01 -06:00
parent ba987d3212
commit 0db6487ce3
2 changed files with 12 additions and 9 deletions

View File

@ -18,7 +18,7 @@ description = "A newly created nostr-rs-relay.\n\nCustomize this with your own i
[diagnostics]
# Enable tokio tracing (for use with tokio-console)
#tracing = true
#tracing = false
[database]
# Directory for SQLite files. Defaults to the current directory. Can

View File

@ -14,22 +14,25 @@ use console_subscriber::ConsoleLayer;
/// Start running a Nostr relay server.
fn main() {
// configure settings from config.toml
// replace default settings with those read from config.toml
let mut settings = config::Settings::new();
// setup tracing
let _trace_sub = tracing_subscriber::fmt::try_init();
if settings.diagnostics.tracing {
// enable tracing with tokio-console
ConsoleLayer::builder().with_default_env().init();
} else {
// standard logging
tracing_subscriber::fmt::try_init().unwrap();
}
info!("Starting up from main");
let args = CLIArgs::parse();
// get database directory from args
let db_dir = args.db;
// configure settings from config.toml
// replace default settings with those read from config.toml
let mut settings = config::Settings::new();
if settings.diagnostics.tracing {
// enable tracing with tokio-console
ConsoleLayer::builder().with_default_env().init();
}
// update with database location
if db_dir.len() > 0 {
settings.database.data_directory = db_dir;