implement a proper logging function, ensure that write_comment doesnt leak