Improve logging for host tags and streamline build information display
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit

Refactor the logging in index.js to handle cases where host tags are absent, ensuring a clear output of "Tags: n/a" when no tags are available. Additionally, simplify the build information logging for better readability by consolidating logger.info calls.
This commit is contained in:
Tom Butcher 2026-07-26 23:34:32 +01:00
parent 9f927b1ef5
commit d616a45f21

View File

@ -30,10 +30,13 @@ const printerHostInfo = (host) => {
logger.info("Reference:", ref);
logger.info("Name:", host?.name || "Unknown");
logger.info("Tags: -", host?.tags?.[0] || "n/a");
for (var i = 0; i < host?.tags?.length - 1; i++) {
const tag = host?.tags[i + 1];
logger.info(" -", tag);
if (host?.tags?.length > 0) {
for (var i = 0; i < host?.tags?.length - 1; i++) {
const tag = host?.tags[i + 1];
logger.info(" -", tag);
}
} else {
logger.info("Tags: n/a");
}
logger.info("State:", host?.state?.type || "Unknown");
};
@ -103,10 +106,7 @@ export async function init(options = {}) {
"Version:",
runningServer.version ? `v${runningServer.version}` : "n/a",
);
logger.info(
"Build:",
buildNumber === "dev" ? "dev" : `b${buildNumber}`,
);
logger.info("Build:", buildNumber === "dev" ? "dev" : `b${buildNumber}`);
logger.info(
"Authenticated:",
runningServer.authenticated == true ? "Yes" : "No",