From ea74c28060e76ae26953bc778c45dea554c63f37 Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Mon, 23 Sep 2024 14:10:12 +0200 Subject: [PATCH] write debug to log and mqtt --- mqtt2prom/run | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mqtt2prom/run b/mqtt2prom/run index 090ee88..52e6991 100755 --- a/mqtt2prom/run +++ b/mqtt2prom/run @@ -64,6 +64,7 @@ $mqtt->onMessage(function ($message) use ( &$news, &$globalCounter, &$isRunning, + &$mqtt, $mqttTopic ) { if ($mqttTopic . "/restart" === $message->topic) { @@ -71,7 +72,7 @@ $mqtt->onMessage(function ($message) use ( return; } if ($mqttTopic . "/debug" === $message->topic) { - logit( + $debug = strval( json_encode( $data, JSON_UNESCAPED_SLASHES + @@ -79,6 +80,9 @@ $mqtt->onMessage(function ($message) use ( JSON_PRETTY_PRINT ) ); + logit($debug); + + $mqtt->publish($mqttTopic . "/debugmsg", $debug, 2); return; } $globalCounter++; @@ -104,6 +108,7 @@ $mqtt->onMessage(function ($message) use ( logit("Subscribing to $mqttTopic with QoS $qos "); $mqtt->subscribe($mqttTopic, $qos); $mqtt->subscribe($mqttTopic . "/restart", $qos); +$mqtt->subscribe($mqttTopic . "/debug", $qos); logit("Subscribed"); $timer = 0;