Core: Make writing of log lines a single fprintf call.

Prior to this change a single line of logging performing several fprintf.

This change gets all the data for a line to be logged in a single
fprintf call. This reduced the chances of writes from another thread
getting intermixed with a log line.

It also makes it easier to change where logs are output to in the future.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>