[ffx][repo] Setting log file base name for repo start
This generates a log file base name based on the repository
name when starting the repository server in non-daemon mode.
Logging is switched to this file ${log.dir}/repo_${reponame}.log
just before invoking FfxMain::main().
In daemon mode, the normal `ffx.daemon.log` file is used.
Bug: b/355277862
Change-Id: I15264ad84ff03893577538ba8207e6ce974c2cf6
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1099632
Reviewed-by: Thomas Zander <thomasalpinus@google.com>
Commit-Queue: Clayton Wilkinson <wilkinsonclay@google.com>
diff --git a/src/developer/ffx/plugins/repository/server/start/src/lib.rs b/src/developer/ffx/plugins/repository/server/start/src/lib.rs
index 2b0a0d2..13561d8 100644
--- a/src/developer/ffx/plugins/repository/server/start/src/lib.rs
+++ b/src/developer/ffx/plugins/repository/server/start/src/lib.rs
@@ -88,6 +88,18 @@
}
}
}
+ fn log_basename(&self) -> Option<String> {
+ match (self.cmd.daemon, self.cmd.foreground) {
+ // Daemon based servers are logged with ffx.daemon.log.
+ (true, _) | (false, false) => return None,
+ _ => {
+ //TODO(https://fxbug.dev/359534719): Move devhost usages to a constant.
+ let basename =
+ format!("repo_{}", self.cmd.repository.clone().unwrap_or("devhost".into()));
+ Some(basename)
+ }
+ }
+ }
}
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
@@ -99,7 +111,6 @@
cmd: StartCommand,
repos: ffx::RepositoryRegistryProxy,
) -> Result<std::net::SocketAddr> {
-
if cmd.no_device
|| !cmd.alias.is_empty()
|| cmd.port_path.is_some()