debug output and flush log