name="hippotat"
path="src/bin/client.rs"
+[[bin]]
+name="hippotatd"
+path="src/bin/server.rs"
+
[dependencies]
hippotat-macros = { path = "macros" }
#[derive(StructOpt,Debug)]
pub struct Opts {
- /// Increase debug level
- #[structopt(long, short="D", parse(from_occurrences))]
- debug: usize,
+ #[structopt(flatten)]
+ log: LogOpts,
#[structopt(flatten)]
config: config::Opts,
let ics = config::read(&opts.config, LinkEnd::Client)?;
if ics.is_empty() { throw!(anyhow!("no associations with server(s)")); }
- {
- let env = env_logger::Env::new()
- .filter("HIPPOTAT_LOG")
- .write_style("HIPPOTAT_LOG_STYLE");
-
- let mut logb = env_logger::Builder::new();
- logb.filter(Some("hippotat"),
- *[ log::LevelFilter::Info,
- log::LevelFilter::Debug ]
- .get(opts.debug)
- .unwrap_or(
- &log::LevelFilter::Trace
- ));
- logb.parse_env(env);
- logb.init();
- }
+ opts.log.log_init()?;
let https = HttpsConnector::new();
let hclient = hyper::Client::builder().build::<_, hyper::Body>(https);
--- /dev/null
+// Copyright 2021 Ian Jackson and contributors to Hippotat
+// SPDX-License-Identifier: GPL-3.0-or-later
+// There is NO WARRANTY.
+
+use hippotat::prelude::*;
+
+#[derive(StructOpt,Debug)]
+pub struct Opts {
+ #[structopt(flatten)]
+ log: LogOpts,
+
+ #[structopt(flatten)]
+ config: config::Opts,
+}
+
+#[tokio::main]
+async fn main() -> Result<(), AE> {
+ let opts = Opts::from_args();
+
+ let ics = config::read(&opts.config, LinkEnd::Server)?;
+
+ opts.log.log_init()?;
+
+ dbg!(ics);
+
+ Ok(())
+}
use crate::prelude::*;
+#[derive(StructOpt,Debug)]
+pub struct LogOpts {
+ /// Increase debug level
+ #[structopt(long, short="D", parse(from_occurrences))]
+ debug: usize,
+}
+
+impl LogOpts {
+ #[throws(AE)]
+ pub fn log_init(&self) {
+ let env = env_logger::Env::new()
+ .filter("HIPPOTAT_LOG")
+ .write_style("HIPPOTAT_LOG_STYLE");
+
+ let mut logb = env_logger::Builder::new();
+ logb.filter(Some("hippotat"),
+ *[ log::LevelFilter::Info,
+ log::LevelFilter::Debug ]
+ .get(self.debug)
+ .unwrap_or(
+ &log::LevelFilter::Trace
+ ));
+ logb.parse_env(env);
+ logb.init();
+ }
+}
+
// For clients only, really.
pub struct Reporter<'r> {
ic: &'r InstanceConfig,