See the Debug module in the official reference and Async Programming for an example of working with Debug.
Debug