make debugging optional and create a log helper