1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Log location ~/.profanity/log/profanity.log

This commit is contained in:
James Booth 2012-07-19 22:38:46 +01:00
parent cfef78bd82
commit 929be7f1ac
4 changed files with 20 additions and 7 deletions

View File

@ -28,22 +28,23 @@
#include <glib.h> #include <glib.h>
static void _create_dir(char *name); #include "common.h"
void p_slist_free_full(GSList *items, GDestroyNotify free_func) void p_slist_free_full(GSList *items, GDestroyNotify free_func)
{ {
g_slist_foreach (items, (GFunc) free_func, NULL); g_slist_foreach (items, (GFunc) free_func, NULL);
g_slist_free (items); g_slist_free (items);
} }
void create_config_directory() void create_config_directory()
{ {
GString *dir = g_string_new(getenv("HOME")); GString *dir = g_string_new(getenv("HOME"));
g_string_append(dir, "/.profanity"); g_string_append(dir, "/.profanity");
_create_dir(dir->str); create_dir(dir->str);
g_string_free(dir, TRUE);
} }
void _create_dir(char *name) void create_dir(char *name)
{ {
int e; int e;
struct stat sb; struct stat sb;

View File

@ -50,6 +50,7 @@ typedef enum {
#endif #endif
void p_slist_free_full(GSList *items, GDestroyNotify free_func); void p_slist_free_full(GSList *items, GDestroyNotify free_func);
void create_config_directory(); void create_config_directory(void);
void create_dir(char *name);
#endif #endif

View File

@ -21,8 +21,12 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "glib.h"
#include "log.h" #include "log.h"
#include "common.h"
extern FILE *logp; extern FILE *logp;
@ -33,7 +37,12 @@ void log_msg(const char * const area, const char * const msg)
void log_init(void) void log_init(void)
{ {
logp = fopen("profanity.log", "a"); GString *log_file = g_string_new(getenv("HOME"));
g_string_append(log_file, "/.profanity/log");
create_dir(log_file->str);
g_string_append(log_file, "/profanity.log");
logp = fopen(log_file->str, "a");
g_string_free(log_file, TRUE);
log_msg(PROF, "Starting Profanity..."); log_msg(PROF, "Starting Profanity...");
} }

View File

@ -22,6 +22,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <glib.h> #include <glib.h>
#include "profanity.h" #include "profanity.h"