ic: &ic,
};
- let mut ipif = Ipif::start(&ic.ipif, ic.to_string())?;
+ let mut ipif = Ipif::start(&ic.ipif, Some(ic.to_string()))?;
let mut req_num: ReqNum = 0;
impl Ipif {
#[throws(AE)]
- pub fn start(cmd: &str, ic_name: String) -> Self {
+ pub fn start(cmd: &str, ic_name: Option<String>) -> Self {
let mut child = tokio::process::Command::new("sh")
.args(&["-c", cmd])
.stdin (process::Stdio::piped())
let stderr_task = task::spawn(async move {
let mut stderr = t_io::BufReader::new(stderr).lines();
while let Some(l) = stderr.next_line().await? {
- error!("{}: ipif stderr: {}", ic_name, l.trim_end());
+ error!("{}ipif stderr: {}",
+ OptionPrefixColon(ic_name.as_ref()),
+ l.trim_end());
}
Ok::<_,io::Error>(())
});
}
}
+pub struct OptionPrefixColon<T>(pub Option<T>);
+impl<T:Display> Display for OptionPrefixColon<T> {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) {
+ if let Some(x) = &self.0 { write!(f, "{}: ", x)? }
+ }
+}
+
// For clients only, really.
pub struct Reporter<'r> {
ic: &'r InstanceConfig,