From c343ff410cc1d4e6cda7ddd85aca492f30964780 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 5 Sep 2012 17:41:35 +0100 Subject: [PATCH] Tidied chat_log module --- src/chat_log.c | 12 ++++++------ src/chat_log.h | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/chat_log.c b/src/chat_log.c index 7c70c8a1..afb60491 100644 --- a/src/chat_log.c +++ b/src/chat_log.c @@ -37,14 +37,14 @@ static void _close_file(gpointer key, gpointer value, gpointer user_data); void chat_log_init(void) { - log_msg(PROF_LEVEL_INFO, "prof", "Initialising chat logs"); + log_info("Initialising chat logs"); tz = g_time_zone_new_local(); logs = g_hash_table_new(NULL, (GEqualFunc) g_strcmp0); } void -chat_log_chat(const char * const login, char *other, - const char * const msg, chat_log_direction_t direction) +chat_log_chat(const gchar * const login, gchar *other, + const gchar * const msg, chat_log_direction_t direction) { gpointer logpp = g_hash_table_lookup(logs, other); FILE *logp; @@ -55,12 +55,12 @@ chat_log_chat(const char * const login, char *other, g_string_append(log_file, "/.profanity/log"); create_dir(log_file->str); - char *login_dir = str_replace(login, "@", "_at_"); + gchar *login_dir = str_replace(login, "@", "_at_"); g_string_append_printf(log_file, "/%s", login_dir); create_dir(log_file->str); free(login_dir); - char *other_file = str_replace(other, "@", "_at_"); + gchar *other_file = str_replace(other, "@", "_at_"); g_string_append_printf(log_file, "/%s.log", other_file); logp = fopen(log_file->str, "a"); free(other_file); @@ -87,7 +87,7 @@ chat_log_chat(const char * const login, char *other, void chat_log_close(void) { - log_msg(PROF_LEVEL_INFO, "prof", "Closing down chat logs"); + log_info("Closing down chat logs"); g_hash_table_foreach(logs, (GHFunc) _close_file, NULL); g_time_zone_unref(tz); } diff --git a/src/chat_log.h b/src/chat_log.h index 100786a6..61763d25 100644 --- a/src/chat_log.h +++ b/src/chat_log.h @@ -23,14 +23,16 @@ #ifndef CHAT_LOG_H #define CHAT_LOG_H +#include + typedef enum { IN, OUT } chat_log_direction_t; void chat_log_init(void); -void chat_log_chat(const char * const login, char *other, - const char * const msg, chat_log_direction_t direction); +void chat_log_chat(const gchar * const login, gchar *other, + const gchar * const msg, chat_log_direction_t direction); void chat_log_close(void); #endif