Let user change log level while running

`/log level INFO|DEBUG|WARN|ERROR` is now available.
Looks like this solves a TODO (see removed comment in source) from 2013
:-)

Works only with default log file. Not with user provided log file during
start up via the -f parameter.

Fix https://github.com/profanity-im/profanity/issues/1627
This commit is contained in:
Michael Vetter
2022-06-22 12:39:44 +02:00
parent 6147a1342d
commit 3f26dd6be9
3 changed files with 17 additions and 4 deletions

View File

@@ -6495,9 +6495,19 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
cons_bad_cmd_usage(command);
if (strcmp(subcmd, "level") == 0) {
if (g_strcmp0(value, "INFO") == 0 || g_strcmp0(value, "DEBUG") == 0 || g_strcmp0(value, "WARN") == 0 || g_strcmp0(value, "ERROR") == 0) {
/* TODO: make 'level' subcommand for debug level */
log_level_t prof_log_level = log_level_from_string(value);
log_close();
log_init(prof_log_level, NULL);
cons_show("Log level changed to: %s.", value);
return TRUE;
}
}
cons_bad_cmd_usage(command);
return TRUE;
}