Added a debug feature for logging to file