Create a separate logging section in config.
This commit is contained in:
parent
e69d2d45bc
commit
4d52f99020
|
@ -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
|
`cargo build --release`. After that launch it with some basic
|
||||||
configuration parameters:
|
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
|
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.
|
Tor Browser and instruct it to use that SOCKS port.
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
# Note that only one process can listen on a given port at a time.
|
# Note that only one process can listen on a given port at a time.
|
||||||
socks_port = 9150
|
socks_port = 9150
|
||||||
|
|
||||||
# Enable logging to journald where available
|
# Configure logging
|
||||||
|
[logging]
|
||||||
|
|
||||||
|
# Enable logging to journald where available
|
||||||
journald = false
|
journald = false
|
||||||
|
|
||||||
# Specify filtering directives for tracing.
|
# Specify filtering directives for tracing.
|
||||||
|
|
|
@ -126,6 +126,20 @@ const ARTI_DEFAULTS: &str = concat!(
|
||||||
include_str!("./authorities.toml"),
|
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
|
||||||
|
/// <https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/filter/struct.EnvFilter.html>
|
||||||
|
///
|
||||||
|
/// 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
|
/// Structure to hold our configuration options, whether from a
|
||||||
/// configuration file or the command line.
|
/// configuration file or the command line.
|
||||||
///
|
///
|
||||||
|
@ -138,14 +152,8 @@ pub struct ArtiConfig {
|
||||||
/// connections.
|
/// connections.
|
||||||
socks_port: Option<u16>,
|
socks_port: Option<u16>,
|
||||||
|
|
||||||
/// Whether to log to journald
|
/// Logging configuration
|
||||||
journald: bool,
|
logging: LoggingConfig,
|
||||||
|
|
||||||
/// Filtering directives that determine tracing levels as described at
|
|
||||||
/// <https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/filter/struct.EnvFilter.html>
|
|
||||||
///
|
|
||||||
/// You can override this setting with the environment variable ARTI_LOG.
|
|
||||||
trace_filter: String,
|
|
||||||
|
|
||||||
/// Information about the Tor network we want to connect to.
|
/// Information about the Tor network we want to connect to.
|
||||||
network: NetworkConfig,
|
network: NetworkConfig,
|
||||||
|
@ -232,13 +240,13 @@ async fn run<R: Runtime>(
|
||||||
fn setup_logging(config: &ArtiConfig) {
|
fn setup_logging(config: &ArtiConfig) {
|
||||||
let env_filter = match EnvFilter::try_from_env("ARTI_LOG") {
|
let env_filter = match EnvFilter::try_from_env("ARTI_LOG") {
|
||||||
Ok(f) => f,
|
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);
|
let registry = registry().with(fmt::Layer::default()).with(env_filter);
|
||||||
|
|
||||||
#[cfg(feature = "journald")]
|
#[cfg(feature = "journald")]
|
||||||
if config.journald {
|
if config.logging.journald {
|
||||||
if let Ok(journald) = tracing_journald::layer() {
|
if let Ok(journald) = tracing_journald::layer() {
|
||||||
registry.with(journald).init();
|
registry.with(journald).init();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue