mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added datetime to chat logging
This commit is contained in:
parent
8e02720a69
commit
3212469bd8
@ -29,6 +29,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static FILE *chatlog;
|
static FILE *chatlog;
|
||||||
|
static GTimeZone *tz;
|
||||||
|
|
||||||
void chat_log_init(void)
|
void chat_log_init(void)
|
||||||
{
|
{
|
||||||
@ -38,15 +39,23 @@ void chat_log_init(void)
|
|||||||
g_string_append(log_file, "/chat.log");
|
g_string_append(log_file, "/chat.log");
|
||||||
chatlog = fopen(log_file->str, "a");
|
chatlog = fopen(log_file->str, "a");
|
||||||
g_string_free(log_file, TRUE);
|
g_string_free(log_file, TRUE);
|
||||||
|
|
||||||
|
tz = g_time_zone_new_local();
|
||||||
}
|
}
|
||||||
|
|
||||||
void chat_log_chat(const char * const user, const char * const msg)
|
void chat_log_chat(const char * const user, const char * const msg)
|
||||||
{
|
{
|
||||||
fprintf(chatlog, "%s: %s\n", user, msg);
|
GDateTime *dt = g_date_time_new_now(tz);
|
||||||
|
gchar *date_fmt = g_date_time_format(dt, "%d/%m/%Y %H:%M:%S");
|
||||||
|
|
||||||
|
fprintf(chatlog, "%s: %s: %s\n", date_fmt, user, msg);
|
||||||
fflush(chatlog);
|
fflush(chatlog);
|
||||||
|
|
||||||
|
g_date_time_unref(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void chat_log_close(void)
|
void chat_log_close(void)
|
||||||
{
|
{
|
||||||
fclose(chatlog);
|
fclose(chatlog);
|
||||||
|
g_time_zone_unref(tz);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user