chiark / gitweb /
parse log config
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 5 Sep 2020 18:29:26 +0000 (19:29 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 5 Sep 2020 18:29:26 +0000 (19:29 +0100)
see also
https://github.com/emabee/flexi_logger/pull/66

Cargo.lock.example
src/global.rs

index 431ed268b5bdefa7890060d52bb9970547728511..33936decb56772a3023bfa9518b632cbc408d909 100644 (file)
@@ -380,8 +380,6 @@ dependencies = [
 [[package]]
 name = "flexi_logger"
 version = "0.15.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aaab3caedb4149800f91e8e4899f29cd9ddf3b569b04c365ca9334f92f7542bf"
 dependencies = [
  "atty",
  "chrono",
index b0007e81aa8f6b06b41e30a8b0a43f80bc17b44c..ca143c26ca5647a7962128f55a6ef8bbc9bbabdd 100644 (file)
@@ -935,7 +935,7 @@ pub struct ServerConfigSpec {
   pub http_port: Option<u16>,
   pub rocket_workers: Option<u16>,
   pub template_dir: Option<String>,
-  pub log: toml::Value,
+  pub log: Option<toml::Value>,
 }
 
 #[derive(Debug,Clone)]
@@ -974,6 +974,17 @@ impl TryFrom<ServerConfigSpec> for ServerConfig {
     let template_dir = template_dir
       .unwrap_or_else(|| DEFAULT_TEMPLATE_DIR.to_owned());
 
+    let log = {
+      use toml::Value::Table;
+      match log {
+        None => Table(Default::default()),
+        Some(log @Table(_)) => log,
+        Some(x) => throw!(anyhow!(
+          r#"wanted table for "log" config key, not {}"#,
+          x.type_str())
+        ),
+      }
+    };
     let log = toml::to_string(&log)?;
     let log = LogSpecification::from_toml(&log)
       .context("log specification")?;