From fb0547a1635e9a69ef99f895aa67ee714aab73c4 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 24 May 2018 15:50:43 +0200 Subject: [PATCH] mqtt: do not show username if not provided --- lib/nodes/mqtt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/nodes/mqtt.c b/lib/nodes/mqtt.c index 17dca2585..f48106661 100644 --- a/lib/nodes/mqtt.c +++ b/lib/nodes/mqtt.c @@ -302,14 +302,17 @@ char * mqtt_print(struct node *n) char *buf = NULL; - strcatf(&buf, "format=%s, host=%s, port=%d, username=%s, keepalive=%s, ssl=%s", plugin_name(m->format), + strcatf(&buf, "format=%s, host=%s, port=%d, keepalive=%s, ssl=%s", plugin_name(m->format), m->host, m->port, - m->username, m->keepalive ? "yes" : "no", m->ssl.enabled ? "yes" : "no" ); + /* Only show if not default */ + if (m->username) + strcatf(&buf, ", username=%s", m->username); + if (m->publish) strcatf(&buf, ", publish=%s", m->publish);