mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added timestamp to log
This commit is contained in:
parent
a371898a5c
commit
e4ac23e9a6
11
src/log.c
11
src/log.c
@ -30,15 +30,22 @@
|
|||||||
|
|
||||||
extern FILE *logp;
|
extern FILE *logp;
|
||||||
|
|
||||||
|
static GTimeZone *tz;
|
||||||
|
static GDateTime *dt;
|
||||||
|
|
||||||
void
|
void
|
||||||
log_msg(const char * const area, const char * const msg)
|
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
|
void
|
||||||
log_init(void)
|
log_init(void)
|
||||||
{
|
{
|
||||||
|
tz = g_time_zone_new_local();
|
||||||
GString *log_file = g_string_new(getenv("HOME"));
|
GString *log_file = g_string_new(getenv("HOME"));
|
||||||
g_string_append(log_file, "/.profanity/log");
|
g_string_append(log_file, "/.profanity/log");
|
||||||
create_dir(log_file->str);
|
create_dir(log_file->str);
|
||||||
@ -51,5 +58,7 @@ log_init(void)
|
|||||||
void
|
void
|
||||||
log_close(void)
|
log_close(void)
|
||||||
{
|
{
|
||||||
|
g_time_zone_unref(tz);
|
||||||
fclose(logp);
|
fclose(logp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user