Flush after chat log writes

This commit is contained in:
James Booth
2012-07-22 21:19:53 +01:00
parent 83ef1d562c
commit 8e02720a69

View File

@@ -25,26 +25,27 @@
#include "glib.h" #include "glib.h"
#include "log.h" #include "chat_log.h"
#include "common.h" #include "common.h"
static FILE *chatlog; static FILE *chatlog;
void chat_log_chat(const char * const user, const char * const msg)
{
fprintf(chatlog, "%s: %s\n", user, msg);
}
void chat_log_init(void) void chat_log_init(void)
{ {
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);
g_string_append(log_file, "/chat.log"); g_string_append(log_file, "/chat.log");
logp = fopen(log_file->str, "a"); chatlog = fopen(log_file->str, "a");
g_string_free(log_file, TRUE); g_string_free(log_file, TRUE);
} }
void chat_log_chat(const char * const user, const char * const msg)
{
fprintf(chatlog, "%s: %s\n", user, msg);
fflush(chatlog);
}
void chat_log_close(void) void chat_log_close(void)
{ {
fclose(chatlog); fclose(chatlog);