changed logging so file/stream logging happens only when debug=True