diff options
author | James Booth <boothj5@gmail.com> | 2012-08-19 01:51:06 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-08-19 01:51:06 +0100 |
commit | e4ac23e9a654004e8e5806c11353887cc1a1aafb (patch) | |
tree | f157b3452f371c520f1bc216ef1b59f004fd56f5 /src | |
parent | a371898a5c9d07a1e4b0a1dd41ca43e72ee49aba (diff) | |
download | profani-tty-e4ac23e9a654004e8e5806c11353887cc1a1aafb.tar.gz |
Added timestamp to log
Diffstat (limited to 'src')
-rw-r--r-- | src/log.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/log.c b/src/log.c index 0e48a123..8998ac73 100644 --- a/src/log.c +++ b/src/log.c @@ -30,15 +30,22 @@ extern FILE *logp; +static GTimeZone *tz; +static GDateTime *dt; + void log_msg(const char * const area, const char * const msg) { - fprintf(logp, "%s DEBUG: %s\n", area, msg); + dt = g_date_time_new_now(tz); + gchar *date_fmt = g_date_time_format(dt, "%d/%m/%Y %H:%M:%S"); + fprintf(logp, "%s: %s DEBUG: %s\n", date_fmt, area, msg); + g_date_time_unref(dt); } void log_init(void) { + tz = g_time_zone_new_local(); GString *log_file = g_string_new(getenv("HOME")); g_string_append(log_file, "/.profanity/log"); create_dir(log_file->str); @@ -51,5 +58,7 @@ log_init(void) void log_close(void) { + g_time_zone_unref(tz); fclose(logp); } + |