[PATCH 3/4] telemetry: replace perror with log

Stephen Hemminger stephen at networkplumber.org
Sun Dec 28 21:10:52 CET 2025


Use logging instead of print to stderr.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/telemetry/telemetry.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index cf4324421d..b109d076d4 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -365,7 +365,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	used += prefix_used;
 	used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
 	if (write(s, out_buf, used) < 0)
-		perror("Error writing to socket");
+		TMTY_LOG_LINE(ERR, "Error writing to socket: %s", strerror(errno));
 }
 
 static void
@@ -384,7 +384,7 @@ perform_command(const struct cmd_callback *cb, const char *cmd, const char *para
 		int used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":null}",
 				MAX_CMD_LEN, cmd ? cmd : "none");
 		if (write(s, out_buf, used) < 0)
-			perror("Error writing to socket");
+			TMTY_LOG_LINE(ERR, "Error writing to socket: %s", strerror(errno));
 		return;
 	}
 	output_json(cmd, &data, s);
-- 
2.51.0



More information about the dev mailing list