feat: make /log level work with non-default files
This commit is contained in:
@@ -1902,9 +1902,9 @@ static const struct cmd_t command_defs[] = {
|
||||
CMD_ARGS(
|
||||
{ "where", "Show the current log file location." },
|
||||
{ "rotate on|off", "Rotate log, default on. Does not take effect if you specified a filename yourself when starting Profanity." },
|
||||
{ "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 10485760 (10MB)." },
|
||||
{ "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 10485760 (10MiB)." },
|
||||
{ "shared on|off", "Share logs between all instances, default: on. When off, the process id will be included in the log filename. Does not take effect if you specified a filename yourself when starting Profanity." },
|
||||
{"level INFO|DEBUG|WARN|ERROR", "Set the log level. Default is INFO. Only works with default log file, not with user provided log file during startup via -f." })
|
||||
{ "level INFO|DEBUG|WARN|ERROR", "Set the log level. Default is INFO." })
|
||||
},
|
||||
|
||||
{ CMD_PREAMBLE("/carbons",
|
||||
|
||||
@@ -6271,10 +6271,11 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
|
||||
if (strcmp(subcmd, "level") == 0) {
|
||||
log_level_t prof_log_level;
|
||||
if (log_level_from_string(value, &prof_log_level) == 0) {
|
||||
auto_char char* log_file = strdup(get_log_file_location());
|
||||
log_close();
|
||||
log_init(prof_log_level, NULL);
|
||||
log_init(prof_log_level, log_file);
|
||||
|
||||
cons_show("Log level changed to: %s.", value);
|
||||
cons_show("Log level changed to: %s (log file: %s).", value, log_file ? log_file : "[default]");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ log_error(const char* const msg, ...)
|
||||
}
|
||||
|
||||
void
|
||||
log_init(log_level_t filter, char* log_file)
|
||||
log_init(log_level_t filter, const char* const log_file)
|
||||
{
|
||||
level_filter = filter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user