check debug flag before exporting log