Skip to content

Commit

Permalink
logger.c: Allow changing max debug level at runtime.
Browse files Browse the repository at this point in the history
Currently, the max debug level when logging to disk
can only be set when the BBS starts up. This has
been made mutable, in case the sysop needs to temporarily
change the log level, e.g. to ensure persistence of
higher log messages when debugging an issue.
  • Loading branch information
InterLinked1 committed Oct 7, 2023
1 parent 3eecedf commit 9b7ea8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions bbs/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,25 @@ static int cli_debug(struct bbs_cli_args *a)
return res < 0 ? res : 0;
}

static int cli_maxdebug(struct bbs_cli_args *a)
{
int oldmax, newmax;

bbs_cli_set_stdout_logging(a->fdout, 1); /* We want to be able to see the logging */
newmax = atoi(a->argv[1]);
if (newmax < 0 || newmax > MAX_DEBUG) {
return -1;
}
oldmax = max_logfile_debug_level;
max_logfile_debug_level = newmax;
bbs_debug(1, "Max file debug level changed from %d to %d\n", oldmax, newmax);
return 0;
}

static struct bbs_cli_entry cli_commands_logger[] = {
BBS_CLI_COMMAND(cli_verbose, "verbose", 2, "Set verbose log level", "verbose <newlevel>"),
BBS_CLI_COMMAND(cli_debug, "debug", 2, "Set debug log level", "debug <newlevel>"),
BBS_CLI_COMMAND(cli_maxdebug, "maxdebug", 2, "Set max file debug log level", "maxdebug <newlevel>"),
};

int bbs_log_init(int nofork)
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_webmail.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ static int client_imap_init(struct ws_session *ws, struct imap_client *client)
res = mailimap_socket_connect(imap, hostname, port);
}
if (MAILIMAP_ERROR(res)) {
bbs_warning("Failed to establish IMAP session to %s:%d\n", hostname, port);
bbs_warning("Failed to establish IMAP session to %s:%d (%s)\n", hostname, port, maildriver_strerror(res));
client_set_error(ws, "IMAP server connection failed");
goto cleanup;
}
Expand Down

0 comments on commit 9b7ea8c

Please sign in to comment.