In xbee.c:xbee_free(...) a call to xbee_log is made after freeing the xbee data structure and its log member.
The call in xbee_log(...) that checks the log level then is unpredictable because the referenced memory has been freed.
This results in the log message being displayed sometimes even if the log level for that instance was set to less than the value associated with the call printing "Completed shutdown procedure....".
In xbee.c:xbee_free(...) a call to xbee_log is made after freeing the xbee data structure and its log member. The call in xbee_log(...) that checks the log level then is unpredictable because the referenced memory has been freed.
This results in the log message being displayed sometimes even if the log level for that instance was set to less than the value associated with the call printing "Completed shutdown procedure....".