Android Question Statement about Error logging with debugger in B4A ?

ciapw

Member
Licensed User
Hi there! please let me know if my statement is true or false!
we can use the Log() feature to track till where our program is being executed.
So, for example I am trying to connect to a mqtt broker with some mqtt function then after that i add the Log() after the mqtt connection function.
Is it true that our program has executed the mqtt connection function after it shows our log in the debugger?

thankyou :)
 

eps

Expert
Licensed User
Longtime User
You have a number of options available to you...

1) Log("Variable Value "& VariableValue) or just a "I'm here processing a specific statement or Function"

2) ToastMessage - these are similar to above but surfaced to the User. They can sometimes be a little slow and get 'stacked' if there are lots.

3) MsgBox - but does interrupt the flow of the

Of course take care if issuing these within Loops, as it can get quite verbose.

See also #BridgeLogger: True - which if set can allow your App to write Log messages when in Release, good for debugging but not desired when Live!

Logs can be filtered - so you only get those in 1) above or unfiltered in which case you get all those in 1) and also 'OS' log messages - which might also help.

HTH
 
Upvote 0

eps

Expert
Licensed User
Longtime User
In your case I'd put a Log message before and after the MQTT statement maybe even a timestamp so I could see the performance
 
Upvote 0

ciapw

Member
Licensed User
In your case I'd put a Log message before and after the MQTT statement maybe even a timestamp so I could see the performance

Thankyou for your replies Mr/Mrs. eps :). What i meant is can we use Log message as an indicator to track the location till where does our program is being executed (as a flag) ?
for example :

B4X:
mqtt_connect 'call mqtt statement
Log("success")
another_program

As my example above, if our log has shown the message we desire then can we conclude that we have succesfully executed the mqtt_connect because or log has shown the "success" message? So, If our log has not shown the "success" message we could conclude that maybe there is a problem within the mqtt_connect because our log was not shown . I hope you could understand my point :)
 
Upvote 0

eps

Expert
Licensed User
Longtime User
It depends if the call stops the thread execution.. I'm not sure it will or does, but I don't know it. Is there not a callback or return value from mqtt_connect? It would be better to check that.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Everything in your code is synchronous. You don't need to rely on the logs for anything.

B4X:
mqtt_connect
another_program
If and only if mqtt_connect has completed successfully then another_program will be executed.

This doesn't mean that the connection was actually established. You need to handle the Connected event (or better wait for it with Wait For).
 
  • Like
Reactions: eps
Upvote 0

ciapw

Member
Licensed User
Everything in your code is synchronous. You don't need to rely on the logs for anything.

B4X:
mqtt_connect
another_program
If and only if mqtt_connect has completed successfully then another_program will be executed.

This doesn't mean that the connection was actually established. You need to handle the Connected event (or better wait for it with Wait For).

So.. i cannot say that Log() can be used as an indicator to track which line of our program is being executed right now?
 
Upvote 0
Top