[th/use-localtime-r] use localtime_r() in g_log_writer_format_fields()
localtime() is not guaranteed to be threadsafe. Use localtime_r() if we have it.
for that, first extract the wrapper around the #ifdef HAVE_LOCALTIME_R
to a separate (internal) helper function.