You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/06/14 09:05:10 UTC

[plc4x] branch develop updated: feat(plc4go): improve logging for subscription

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7615701e13 feat(plc4go): improve logging for subscription
7615701e13 is described below

commit 7615701e13dddd4138ea04b4fca1d721afda5b73
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Jun 14 11:05:00 2023 +0200

    feat(plc4go): improve logging for subscription
---
 plc4go/internal/cbus/Connection.go | 7 +++++--
 plc4go/internal/cbus/Driver.go     | 2 +-
 plc4go/internal/cbus/Subscriber.go | 9 ++++++++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/plc4go/internal/cbus/Connection.go b/plc4go/internal/cbus/Connection.go
index d8c0e872c1..99638f10f0 100644
--- a/plc4go/internal/cbus/Connection.go
+++ b/plc4go/internal/cbus/Connection.go
@@ -222,8 +222,11 @@ func (c *Connection) setupConnection(ctx context.Context, ch chan plc4go.PlcConn
 		c.log.Trace().Msg("Set interface options 1 failed")
 		return
 	}
+	c.log.Trace().Msg("Connection setup done")
 	c.fireConnected(ch)
+	c.log.Trace().Msg("Connect fired")
 	c.startSubscriptionHandler()
+	c.log.Trace().Msg("subscription handler started")
 }
 
 func (c *Connection) startSubscriptionHandler() {
@@ -240,7 +243,7 @@ func (c *Connection) startSubscriptionHandler() {
 				handled := false
 				for _, subscriber := range c.subscribers {
 					if ok := subscriber.handleMonitoredSAL(monitoredSal); ok {
-						c.log.Debug().Msgf("%v handled\n%s", subscriber, monitoredSal)
+						c.log.Debug().Msgf("\n%v handled\n%s", subscriber, monitoredSal)
 						handled = true
 					}
 				}
@@ -264,7 +267,7 @@ func (c *Connection) startSubscriptionHandler() {
 				handled := false
 				for _, subscriber := range c.subscribers {
 					if ok := subscriber.handleMonitoredMMI(calReply); ok {
-						c.log.Debug().Msgf("%v handled\n%s", subscriber, calReply)
+						c.log.Debug().Msgf("\n%v handled\n%s", subscriber, calReply)
 						handled = true
 					}
 				}
diff --git a/plc4go/internal/cbus/Driver.go b/plc4go/internal/cbus/Driver.go
index 08fabaf5d3..62011b5f56 100644
--- a/plc4go/internal/cbus/Driver.go
+++ b/plc4go/internal/cbus/Driver.go
@@ -79,7 +79,7 @@ func (m *Driver) GetConnectionWithContext(ctx context.Context, transportUrl url.
 	}
 
 	codec := NewMessageCodec(transportInstance, options.WithCustomLogger(m.log))
-	m.log.Debug().Msgf("working with codec %#v", codec)
+	m.log.Debug().Msgf("working with codec:\n%s", codec)
 
 	driverContext := NewDriverContext(configuration)
 	driverContext.awaitSetupComplete = m.awaitSetupComplete
diff --git a/plc4go/internal/cbus/Subscriber.go b/plc4go/internal/cbus/Subscriber.go
index 04ba4bc154..7b987b83f3 100644
--- a/plc4go/internal/cbus/Subscriber.go
+++ b/plc4go/internal/cbus/Subscriber.go
@@ -102,6 +102,7 @@ func (s *Subscriber) Unsubscribe(ctx context.Context, unsubscriptionRequest apiM
 }
 
 func (s *Subscriber) handleMonitoredMMI(calReply readWriteModel.CALReply) bool {
+	s.log.Debug().Msgf("handling:\n%s", calReply)
 	var unitAddressString string
 	switch calReply := calReply.(type) {
 	case readWriteModel.CALReplyLongExactly:
@@ -118,13 +119,19 @@ func (s *Subscriber) handleMonitoredMMI(calReply readWriteModel.CALReply) bool {
 	default:
 		unitAddressString = "u0" // On short form it should be always unit 0 TODO: double check that
 	}
+	s.log.Debug().Msgf("Unit address string: %s", unitAddressString)
 	calData := calReply.GetCalData()
 	handled := false
 	for registration, consumer := range s.consumers {
+		s.log.Debug().Msgf("Checking with registration\n%s\nand consumer set %t", registration, consumer != nil)
 		for _, subscriptionHandle := range registration.GetSubscriptionHandles() {
-			handled = handled || s.offerMMI(unitAddressString, calData, subscriptionHandle.(*SubscriptionHandle), consumer)
+			s.log.Debug().Msgf("offering to\n%s", subscriptionHandle)
+			handleHandled := s.offerMMI(unitAddressString, calData, subscriptionHandle.(*SubscriptionHandle), consumer)
+			s.log.Debug().Msgf("handle handled: %t", handleHandled)
+			handled = handled || handleHandled
 		}
 	}
+	s.log.Debug().Msgf("final handled: %t", handled)
 	return handled
 }