mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Use whole path as logfile when defined via -f
`profanity -f my` created ~/.local/share/profanity/logs/my.log`. It would be nicer if one could define the actual path, so one can choose another directory or even use /dev/null. Fixes https://github.com/profanity-im/profanity/issues/1442
This commit is contained in:
parent
560a15e2a9
commit
a8990014e2
@ -116,20 +116,26 @@ char*
|
|||||||
files_get_log_file(const char* const log_file)
|
files_get_log_file(const char* const log_file)
|
||||||
{
|
{
|
||||||
gchar* xdg_data = _files_get_xdg_data_home();
|
gchar* xdg_data = _files_get_xdg_data_home();
|
||||||
GString* logfile = g_string_new(xdg_data);
|
GString* logfile;
|
||||||
|
|
||||||
if (log_file) {
|
if (log_file) {
|
||||||
g_string_append(logfile, "/profanity/logs/");
|
gchar *log_path = g_path_get_dirname(log_file);
|
||||||
g_string_append(logfile, log_file);
|
if (!mkdir_recursive(log_path)) {
|
||||||
|
log_error("Error while creating directory %s", log_path);
|
||||||
|
}
|
||||||
|
g_free(log_path);
|
||||||
|
|
||||||
|
logfile = g_string_new(log_file);
|
||||||
} else {
|
} else {
|
||||||
|
logfile = g_string_new(xdg_data);
|
||||||
g_string_append(logfile, "/profanity/logs/profanity");
|
g_string_append(logfile, "/profanity/logs/profanity");
|
||||||
}
|
|
||||||
|
|
||||||
if (!prefs_get_boolean(PREF_LOG_SHARED)) {
|
if (!prefs_get_boolean(PREF_LOG_SHARED)) {
|
||||||
g_string_append_printf(logfile, "%d", getpid());
|
g_string_append_printf(logfile, "%d", getpid());
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append(logfile, ".log");
|
g_string_append(logfile, ".log");
|
||||||
|
}
|
||||||
|
|
||||||
char* result = g_strdup(logfile->str);
|
char* result = g_strdup(logfile->str);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user