about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-21 21:10:00 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-21 21:10:00 +0100
commit75cfe38808e76a5308dac7023876a9826ed56347 (patch)
tree4138100b492967b704007e3bde130cce4cc98269 /src/config
parent99dc1c9494f5f84fae4082bac2a0dec5319232ce (diff)
downloadprofani-tty-75cfe38808e76a5308dac7023876a9826ed56347.tar.gz
Allow setting custom log file via -f FILENAME
`profanity -f TEST` will use `~/.local/share/profanity/logs/TEST.log` as
the log file.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/files.c14
-rw-r--r--src/config/files.h2
2 files changed, 13 insertions, 3 deletions
diff --git a/src/config/files.c b/src/config/files.c
index 25b25c54..133a270e 100644
--- a/src/config/files.c
+++ b/src/config/files.c
@@ -112,16 +112,26 @@ files_get_inputrc_file(void)
 }
 
 char*
-files_get_log_file(void)
+files_get_log_file(char *log_file)
 {
     gchar *xdg_data = _files_get_xdg_data_home();
     GString *logfile = g_string_new(xdg_data);
-    g_string_append(logfile, "/profanity/logs/profanity");
+
+    if (log_file) {
+        g_string_append(logfile, "/profanity/logs/");
+        g_string_append(logfile, log_file);
+    } else {
+        g_string_append(logfile, "/profanity/logs/profanity");
+    }
+
     if (!prefs_get_boolean(PREF_LOG_SHARED)) {
         g_string_append_printf(logfile, "%d", getpid());
     }
+
     g_string_append(logfile, ".log");
+
     char *result = strdup(logfile->str);
+
     free(xdg_data);
     g_string_free(logfile, TRUE);
 
diff --git a/src/config/files.h b/src/config/files.h
index b5cc5e1b..12c3f03a 100644
--- a/src/config/files.h
+++ b/src/config/files.h
@@ -61,7 +61,7 @@ void files_create_directories(void);
 char* files_get_config_path(char *config_base);
 char* files_get_data_path(char *data_base);
 
-char* files_get_log_file(void);
+char* files_get_log_file(char *log_file);
 char* files_get_inputrc_file(void);
 
 #endif