summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mod.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 9210922..5837d1e 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -110,6 +110,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
"HTTP API users (from htpasswd) who may write protocol data under /store/_continuum (remake records, members, forget records), e.g. to repair a stuck remake. Such writes act on the whole swarm and are logged. Epoch metadata and the swarm ID are never writable.",
),
option(
+ "log-format",
+ Kind::Text,
+ "auto|text|journal",
+ Some("auto"),
+ "How log lines look: `text` (timestamped), `journal` (for systemd's journal: no timestamp or colours, the level as each line's priority, for journalctl -p), or `auto`: journal when stdout goes to the journal, else text.",
+ ),
+ option(
"log-raw-ids",
Kind::Flag,
"BOOL",
@@ -390,6 +397,8 @@ pub(crate) struct Settings {
pub(crate) protocol_writers: Vec<String>,
#[serde(default)]
pub(crate) debug_api: bool,
+ #[serde(default = "default_log_format")]
+ pub(crate) log_format: String,
#[serde(default)]
pub(crate) log_raw_ids: bool,
#[serde(default)]
@@ -499,6 +508,9 @@ pub(crate) const TRANSPORTS: &[(&str, bool)] = &[
("libp2p", cfg!(feature = "libp2p")),
("tor", cfg!(feature = "tor")),
];
+fn default_log_format() -> String {
+ "auto".to_owned()
+}
fn default_tor_port() -> u16 {
9662
}
@@ -535,6 +547,13 @@ impl Settings {
}
fn check(&self) -> Result<()> {
+ if crate::logging::LogFormat::parse(&self.log_format).is_none() {
+ bail!(
+ "log-format {:?}: one of {}",
+ self.log_format,
+ crate::logging::LogFormat::NAMES.join(", ")
+ );
+ }
if let Some(url) = &self.mycelium_rest_url {
url::Url::parse(url).with_context(|| format!("mycelium-rest-url {url:?}"))?;
}