1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Create logs dir for main log

This commit is contained in:
James Booth 2012-12-02 01:01:27 +00:00
parent 489c0c6bd3
commit 30e4786180
3 changed files with 69 additions and 49 deletions

View File

@ -29,51 +29,22 @@
#include <glib.h> #include <glib.h>
static void _files_create_config_directory(void);
static void _files_create_data_directory(void);
static void _files_create_chatlog_directory(void);
static void _files_create_log_directory(void);
static void _files_create_themes_directory(void);
static void _create_dir(char *name); static void _create_dir(char *name);
static void _mkdir_recursive(const char *dir); static void _mkdir_recursive(const char *dir);
void void
files_create_config_directory(void) files_create_directories(void)
{ {
gchar *xdg_config = xdg_get_config_home(); _files_create_config_directory();
GString *prof_conf_dir = g_string_new(xdg_config); _files_create_data_directory();
g_string_append(prof_conf_dir, "/profanity"); _files_create_chatlog_directory();
_mkdir_recursive(prof_conf_dir->str); _files_create_log_directory();
g_free(xdg_config); _files_create_themes_directory();
g_string_free(prof_conf_dir, TRUE);
}
void
files_create_data_directory(void)
{
gchar *xdg_data = xdg_get_data_home();
GString *prof_data_dir = g_string_new(xdg_data);
g_string_append(prof_data_dir, "/profanity");
_mkdir_recursive(prof_data_dir->str);
g_free(xdg_data);
g_string_free(prof_data_dir, TRUE);
}
void
files_create_chatlog_directory(void)
{
gchar *xdg_data = xdg_get_data_home();
GString *chatlogs_dir = g_string_new(xdg_data);
g_string_append(chatlogs_dir, "/profanity/chatlogs");
_mkdir_recursive(chatlogs_dir->str);
g_free(xdg_data);
g_string_free(chatlogs_dir, TRUE);
}
void
files_create_themes_directory(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *themes_dir = g_string_new(xdg_config);
g_string_append(themes_dir, "/profanity/themes");
_mkdir_recursive(themes_dir->str);
g_free(xdg_config);
g_string_free(themes_dir, TRUE);
} }
gchar * gchar *
@ -107,7 +78,7 @@ files_get_log_file(void)
{ {
gchar *xdg_data = xdg_get_data_home(); gchar *xdg_data = xdg_get_data_home();
GString *logfile = g_string_new(xdg_data); GString *logfile = g_string_new(xdg_data);
g_string_append(logfile, "/profanity/profanity.log"); g_string_append(logfile, "/profanity/logs/profanity.log");
gchar *result = strdup(logfile->str); gchar *result = strdup(logfile->str);
g_free(xdg_data); g_free(xdg_data);
g_string_free(logfile, TRUE); g_string_free(logfile, TRUE);
@ -128,6 +99,61 @@ files_get_themes_dir(void)
return result; return result;
} }
static void
_files_create_config_directory(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *prof_conf_dir = g_string_new(xdg_config);
g_string_append(prof_conf_dir, "/profanity");
_mkdir_recursive(prof_conf_dir->str);
g_free(xdg_config);
g_string_free(prof_conf_dir, TRUE);
}
static void
_files_create_data_directory(void)
{
gchar *xdg_data = xdg_get_data_home();
GString *prof_data_dir = g_string_new(xdg_data);
g_string_append(prof_data_dir, "/profanity");
_mkdir_recursive(prof_data_dir->str);
g_free(xdg_data);
g_string_free(prof_data_dir, TRUE);
}
static void
_files_create_chatlog_directory(void)
{
gchar *xdg_data = xdg_get_data_home();
GString *chatlogs_dir = g_string_new(xdg_data);
g_string_append(chatlogs_dir, "/profanity/chatlogs");
_mkdir_recursive(chatlogs_dir->str);
g_free(xdg_data);
g_string_free(chatlogs_dir, TRUE);
}
static void
_files_create_log_directory(void)
{
gchar *xdg_data = xdg_get_data_home();
GString *chatlogs_dir = g_string_new(xdg_data);
g_string_append(chatlogs_dir, "/profanity/logs");
_mkdir_recursive(chatlogs_dir->str);
g_free(xdg_data);
g_string_free(chatlogs_dir, TRUE);
}
static void
_files_create_themes_directory(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *themes_dir = g_string_new(xdg_config);
g_string_append(themes_dir, "/profanity/themes");
_mkdir_recursive(themes_dir->str);
g_free(xdg_config);
g_string_free(themes_dir, TRUE);
}
static void static void
_create_dir(char *name) _create_dir(char *name)
{ {

View File

@ -23,10 +23,7 @@
#ifndef FILES_H #ifndef FILES_H
#define FILES_H #define FILES_H
void files_create_config_directory(void); void files_create_directories(void);
void files_create_data_directory(void);
void files_create_chatlog_directory(void);
void files_create_themes_directory(void);
gchar* files_get_chatlog_dir(void); gchar* files_get_chatlog_dir(void);
gchar* files_get_preferences_file(void); gchar* files_get_preferences_file(void);
gchar* files_get_log_file(void); gchar* files_get_log_file(void);

View File

@ -502,10 +502,7 @@ _init(const int disable_tls, char *log_level)
{ {
// ignore SIGPIPE // ignore SIGPIPE
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
files_create_config_directory(); files_create_directories();
files_create_data_directory();
files_create_chatlog_directory();
files_create_themes_directory();
log_level_t prof_log_level = _get_log_level(log_level); log_level_t prof_log_level = _get_log_level(log_level);
log_init(prof_log_level); log_init(prof_log_level);
log_info("Starting Profanity (%s)...", PACKAGE_VERSION); log_info("Starting Profanity (%s)...", PACKAGE_VERSION);