How to capture console events when you run into a bug