Added a log writing function.