mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 01:14:43 +00:00
trivial: minor optimization for no timestamp case
This commit is contained in:
parent
eaf7f0b529
commit
4b69830e1c
@ -66,8 +66,7 @@ fu_debug_handler_cb (const gchar *log_domain,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
FuDebug *self = (FuDebug *) user_data;
|
FuDebug *self = (FuDebug *) user_data;
|
||||||
g_autofree gchar *tmp = NULL;
|
g_autofree gchar *timestamp = NULL;
|
||||||
g_autoptr(GDateTime) dt = g_date_time_new_now_utc ();
|
|
||||||
g_autoptr(GString) domain = NULL;
|
g_autoptr(GString) domain = NULL;
|
||||||
|
|
||||||
/* should ignore */
|
/* should ignore */
|
||||||
@ -76,7 +75,8 @@ fu_debug_handler_cb (const gchar *log_domain,
|
|||||||
|
|
||||||
/* time header */
|
/* time header */
|
||||||
if (!self->no_timestamp) {
|
if (!self->no_timestamp) {
|
||||||
tmp = g_strdup_printf ("%02i:%02i:%02i:%04i",
|
g_autoptr(GDateTime) dt = g_date_time_new_now_utc ();
|
||||||
|
timestamp = g_strdup_printf ("%02i:%02i:%02i:%04i",
|
||||||
g_date_time_get_hour (dt),
|
g_date_time_get_hour (dt),
|
||||||
g_date_time_get_minute (dt),
|
g_date_time_get_minute (dt),
|
||||||
g_date_time_get_second (dt),
|
g_date_time_get_second (dt),
|
||||||
@ -96,8 +96,8 @@ fu_debug_handler_cb (const gchar *log_domain,
|
|||||||
/* to file */
|
/* to file */
|
||||||
if (!self->console) {
|
if (!self->console) {
|
||||||
g_autofree gchar *ascii_message = g_str_to_ascii (message, NULL);
|
g_autofree gchar *ascii_message = g_str_to_ascii (message, NULL);
|
||||||
if (tmp != NULL)
|
if (timestamp != NULL)
|
||||||
g_printerr ("%s ", tmp);
|
g_printerr ("%s ", timestamp);
|
||||||
if (domain != NULL)
|
if (domain != NULL)
|
||||||
g_printerr ("%s ", domain->str);
|
g_printerr ("%s ", domain->str);
|
||||||
g_printerr ("%s\n", ascii_message);
|
g_printerr ("%s\n", ascii_message);
|
||||||
@ -110,16 +110,16 @@ fu_debug_handler_cb (const gchar *log_domain,
|
|||||||
case G_LOG_LEVEL_CRITICAL:
|
case G_LOG_LEVEL_CRITICAL:
|
||||||
case G_LOG_LEVEL_WARNING:
|
case G_LOG_LEVEL_WARNING:
|
||||||
/* critical in red */
|
/* critical in red */
|
||||||
if (tmp != NULL)
|
if (timestamp != NULL)
|
||||||
g_printerr ("%c[%dm%s ", 0x1B, 32, tmp);
|
g_printerr ("%c[%dm%s ", 0x1B, 32, timestamp);
|
||||||
if (domain != NULL)
|
if (domain != NULL)
|
||||||
g_printerr ("%s ", domain->str);
|
g_printerr ("%s ", domain->str);
|
||||||
g_printerr ("%c[%dm%s\n%c[%dm", 0x1B, 31, message, 0x1B, 0);
|
g_printerr ("%c[%dm%s\n%c[%dm", 0x1B, 31, message, 0x1B, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* debug in blue */
|
/* debug in blue */
|
||||||
if (tmp != NULL)
|
if (timestamp != NULL)
|
||||||
g_printerr ("%c[%dm%s ", 0x1B, 32, tmp);
|
g_printerr ("%c[%dm%s ", 0x1B, 32, timestamp);
|
||||||
if (domain != NULL)
|
if (domain != NULL)
|
||||||
g_printerr ("%s ", domain->str);
|
g_printerr ("%s ", domain->str);
|
||||||
g_printerr ("%c[%dm%s\n%c[%dm", 0x1B, 34, message, 0x1B, 0);
|
g_printerr ("%c[%dm%s\n%c[%dm", 0x1B, 34, message, 0x1B, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user