mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Fix /log level
crash
Fix crash caused by `/log level` command. Minor refactoring of command function.
This commit is contained in:
parent
4933d4e4f3
commit
5a1f2dedd3
@ -6516,12 +6516,17 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
|
|||||||
char* subcmd = args[0];
|
char* subcmd = args[0];
|
||||||
char* value = args[1];
|
char* value = args[1];
|
||||||
|
|
||||||
if (strcmp(subcmd, "maxsize") == 0) {
|
if (strcmp(subcmd, "where") == 0) {
|
||||||
if (value == NULL) {
|
cons_show("Log file: %s", get_log_file_location());
|
||||||
cons_bad_cmd_usage(command);
|
return TRUE;
|
||||||
return TRUE;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if (value == NULL) {
|
||||||
|
cons_bad_cmd_usage(command);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(subcmd, "maxsize") == 0) {
|
||||||
int intval = 0;
|
int intval = 0;
|
||||||
char* err_msg = NULL;
|
char* err_msg = NULL;
|
||||||
gboolean res = strtoi_range(value, &intval, PREFS_MIN_LOG_SIZE, INT_MAX, &err_msg);
|
gboolean res = strtoi_range(value, &intval, PREFS_MIN_LOG_SIZE, INT_MAX, &err_msg);
|
||||||
@ -6536,29 +6541,16 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(subcmd, "rotate") == 0) {
|
if (strcmp(subcmd, "rotate") == 0) {
|
||||||
if (value == NULL) {
|
|
||||||
cons_bad_cmd_usage(command);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
_cmd_set_boolean_preference(value, command, "Log rotate", PREF_LOG_ROTATE);
|
_cmd_set_boolean_preference(value, command, "Log rotate", PREF_LOG_ROTATE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(subcmd, "shared") == 0) {
|
if (strcmp(subcmd, "shared") == 0) {
|
||||||
if (value == NULL) {
|
|
||||||
cons_bad_cmd_usage(command);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
_cmd_set_boolean_preference(value, command, "Shared log", PREF_LOG_SHARED);
|
_cmd_set_boolean_preference(value, command, "Shared log", PREF_LOG_SHARED);
|
||||||
cons_show("Setting only takes effect after saving and restarting Profanity.");
|
cons_show("Setting only takes effect after saving and restarting Profanity.");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(subcmd, "where") == 0) {
|
|
||||||
cons_show("Log file: %s", get_log_file_location());
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(subcmd, "level") == 0) {
|
if (strcmp(subcmd, "level") == 0) {
|
||||||
log_level_t prof_log_level;
|
log_level_t prof_log_level;
|
||||||
if (log_level_from_string(value, &prof_log_level) == 0) {
|
if (log_level_from_string(value, &prof_log_level) == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user