Introduce prof_date_time_format_iso8601().

Instead of repeating the same pattern over and over, introduce a helper
function that either outputs a formatted timestamp if one is given as
argument or returns the current time if no argument is given.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2026-03-17 17:29:18 +01:00
parent f55f7611c2
commit 349de02b8c
6 changed files with 22 additions and 35 deletions

View File

@@ -204,14 +204,11 @@ log_close(void)
static void
_log_msg(log_level_t level, const char* const area, const char* const msg)
{
GDateTime* dt = g_date_time_new_now_local();
char* level_str = _log_abbreviation_string_from_level(level);
auto_gchar gchar* date_fmt = g_date_time_format_iso8601(dt);
auto_gchar gchar* date_fmt = prof_date_time_format_iso8601(NULL);
fprintf(logp, "%s: %08d: %s: %s: %s\n", date_fmt, prof_pid, area, level_str, msg);
g_date_time_unref(dt);
fflush(logp);