Here are a few things I’ve noticed when trying to write a service manager:
If you call a parent function from the child, you don’t see any logging that the parent would have sent. The same for the opposite scenario. I’ve seen the out of order logging as well. I am pretty sure these are both artifacts of the way the threading of the various event processing is handled. The second one is very common in multithreaded logging environments. Many logging environments actually have a process number and/or name associated with each line similar to what ST does with it’s various SmartApps and devices but would also include a subprocess number. As far as lines going missing, I wouldn’t be surprised if there is a maximum amount of output that can be sent from one execution of a process.
Thread synchronization methods don’t seem to be any accessible (probably for performance reasons) which means you can’t wait in a process for a variable to be updated in another process. From what I’ve seen once you read a variable in a process (call it A), you cannot get a new value updated by process B until the next execution of A. I think all notions of volatile and thread synchronization primitives are disabled. Events or scheduled processes basically handle this function although they can be more complicated to deal with as your SmartApp gets more complex.
I’ve spent a good amount of trial and error effort in debugging these interactions and it’s not easy. One of the things I try is to periodically uninstall my SmartApp and device type and restart to make sure it’s cleaned up. I also use the main log window and reselect “Log” when I’m not seeing data to make sure it’s still connected to the server correctly. Some of it’s like voodoo though.
All of this is trial and error speculation really, so please anyone correct me if I’m mistaken.