diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d1fc6584..2a3a75071 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -101,7 +101,7 @@ To do so, we will launch arti independently from Tor Browser. Build arti with `cargo build --release`. After that launch it with some basic configuration parameters: - $ ./target/release/arti -c "socks_port = 9150" -c "trace_filter = 'debug'" + $ ./target/release/arti -c "socks_port = 9150" -c "logging.trace_filter = 'debug'" This will ensure that arti sets its SOCKS port on 9150. Now we need to launch Tor Browser and instruct it to use that SOCKS port. diff --git a/crates/arti/src/arti_defaults.toml b/crates/arti/src/arti_defaults.toml index a108e16d5..f2e69a265 100644 --- a/crates/arti/src/arti_defaults.toml +++ b/crates/arti/src/arti_defaults.toml @@ -6,8 +6,10 @@ # Note that only one process can listen on a given port at a time. socks_port = 9150 -# Enable logging to journald where available +# Configure logging +[logging] +# Enable logging to journald where available journald = false # Specify filtering directives for tracing. diff --git a/crates/arti/src/main.rs b/crates/arti/src/main.rs index ed42e83fc..1dee82814 100644 --- a/crates/arti/src/main.rs +++ b/crates/arti/src/main.rs @@ -126,6 +126,20 @@ const ARTI_DEFAULTS: &str = concat!( include_str!("./authorities.toml"), ); +/// Structure to hold our logging configuration options +#[derive(Deserialize, Debug, Clone)] +#[serde(deny_unknown_fields)] +struct LoggingConfig { + /// Filtering directives that determine tracing levels as described at + /// + /// + /// You can override this setting with the environment variable ARTI_LOG. + trace_filter: String, + + /// Whether to log to journald + journald: bool, +} + /// Structure to hold our configuration options, whether from a /// configuration file or the command line. /// @@ -138,14 +152,8 @@ pub struct ArtiConfig { /// connections. socks_port: Option, - /// Whether to log to journald - journald: bool, - - /// Filtering directives that determine tracing levels as described at - /// - /// - /// You can override this setting with the environment variable ARTI_LOG. - trace_filter: String, + /// Logging configuration + logging: LoggingConfig, /// Information about the Tor network we want to connect to. network: NetworkConfig, @@ -232,13 +240,13 @@ async fn run( fn setup_logging(config: &ArtiConfig) { let env_filter = match EnvFilter::try_from_env("ARTI_LOG") { Ok(f) => f, - Err(_e) => EnvFilter::new(config.trace_filter.as_str()), + Err(_e) => EnvFilter::new(config.logging.trace_filter.as_str()), }; let registry = registry().with(fmt::Layer::default()).with(env_filter); #[cfg(feature = "journald")] - if config.journald { + if config.logging.journald { if let Ok(journald) = tracing_journald::layer() { registry.with(journald).init(); return;