From 415451a8fb2dadb2dd08af5d4a5760c2461f45ce Mon Sep 17 00:00:00 2001 From: Matthew Slowe Date: Sun, 24 Jan 2021 14:32:02 +0000 Subject: [PATCH] logging better --- update-berths.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/update-berths.pl b/update-berths.pl index d35cc5b..2e6e7b4 100755 --- a/update-berths.pl +++ b/update-berths.pl @@ -39,7 +39,7 @@ sub handle($$) { }; if ($data) { - # _debug( "[$topic] " . summary($data) ); + _debug( "[$topic] " . summary($data) ); foreach (@{$data}) { process_message($_); } @@ -66,13 +66,13 @@ sub process_message($) { clear_berth($inner{area_id}, $inner{from}); set_berth($inner{area_id}, $inner{to}, $inner{descr}); - # "STEP: $inner{area_id} $inner{to} := $inner{descr} at $inner{time}\n"; + _debug( "STEP: $inner{area_id} $inner{to} := $inner{descr} at $inner{time}" ); } elsif($type eq 'CB_MSG') { clear_berth($inner{area_id}, $inner{from}); - # "CLEAR: $inner{area_id} $inner{from} at $inner{time}\n"; + _debug( "CLEAR: $inner{area_id} $inner{from} at $inner{time}" ); } elsif($type eq 'CC_MSG') { set_berth($inner{area_id}, $inner{to}, $inner{descr}); - # "INTERPOSE: $inner{area_id} $inner{to} := $inner{descr} at $inner{time}\n"; + _debug( "INTERPOSE: $inner{area_id} $inner{to} := $inner{descr} at $inner{time}" ); } else { # print "SKIPPING MESSAGE\n"; } @@ -112,8 +112,10 @@ $mqtt = Net::MQTT::Simple->new($ENV{MQTT_SERVER}) or die "Failed to connect to m $mqtt->subscribe( "$ENV{MQTT_MONITOR}" => sub { my ($topic, $message) = @_; + _debug("--> $topic"); handle($topic, $message); }, ); +_debug("Ready to receive messages"); -$mqtt->run(); \ No newline at end of file +$mqtt->run();