log: Replace deprecated functions with modern equivalents

This commit is contained in:
Robert Ancell 2019-09-27 12:09:16 +12:00 committed by Georges Basile Stavracas Neto
parent 6d7e552ae1
commit 92e1abf6f2

View file

@ -54,11 +54,9 @@ log_handler (const gchar *domain,
const gchar *message, const gchar *message,
gpointer user_data) gpointer user_data)
{ {
GTimeVal tv; g_autoptr(GDateTime) now = NULL;
struct tm tt;
time_t t;
const gchar *level; const gchar *level;
gchar ftime[32]; g_autofree gchar *ftime = NULL;
gchar *buffer; gchar *buffer;
/* Skip ignored log domains */ /* Skip ignored log domains */
@ -66,13 +64,11 @@ log_handler (const gchar *domain,
return; return;
level = log_level_str (log_level); level = log_level_str (log_level);
g_get_current_time (&tv); now = g_date_time_new_now_local ();
t = (time_t) tv.tv_sec; ftime = g_date_time_format (now, "%H:%M:%S");
tt = *localtime (&t); buffer = g_strdup_printf ("%s.%04d %24s: %s: %s\n",
strftime (ftime, sizeof (ftime), "%H:%M:%S", &tt);
buffer = g_strdup_printf ("%s.%04ld %24s: %s: %s\n",
ftime, ftime,
tv.tv_usec / 1000, g_date_time_get_microsecond (now) / 1000,
domain, domain,
level, level,
message); message);