jcs
/subtext
/amendments
/245
logger: Add buffered logging, support logging without updating window
During telnet negotiation, many lines are logged in quick succession
which means we spend a lot of time updating the log TextEdit. Just
buffer these logs and spit them out all at once upon login or
disconnection, so the user's login prompt is immediately responsive.
Rename session_log to session_logf while I'm in here, to reflect that
it's a format-string function.
jcs made amendment 245 over 2 years ago
--- ansi.c Sun Jul 31 18:09:04 2022
+++ ansi.c Fri Jan 1 02:02:55 1904
@@ -300,9 +300,9 @@ ansi_probe_screen_size(struct session *s)
if (cols >= MIN_TERMINAL_COLUMNS && rows >= MIN_TERMINAL_LINES) {
s->terminal_columns = cols;
s->terminal_lines = rows;
- session_log(s, "Probed terminal size of %dx%d", cols, rows);
+ session_logf(s, "Probed terminal size of %dx%d", cols, rows);
} else {
- session_log(s, "Bogus terminal size probe response: %dx%d",
+ session_logf(s, "Bogus terminal size probe response: %dx%d",
cols, rows);
}
}
--- board.c Mon Aug 1 15:25:57 2022
+++ board.c Fri Jan 1 02:03:04 1904
@@ -490,7 +490,7 @@ post_compose_start:
session_flush(s);
if (board_post_create(board, thread, &post) == 0) {
- session_log(s, "Posted message %ld to %s", post.id,
+ session_logf(s, "Posted message %ld to %s", post.id,
board->name);
session_printf(s, "done\r\n");
} else
@@ -626,7 +626,7 @@ board_post_read(struct session *s, struct board *board
board_delete_post(s, board, &post, &thread);
- session_log(s, "Deleted post %ld (thread %ld)", post.id,
+ session_logf(s, "Deleted post %ld (thread %ld)", post.id,
thread.thread_id);
session_printf(s, "\r\n{{B}}Post deleted!{{/B}}\r\n");
--- chat.c Sat Aug 13 14:49:46 2022
+++ chat.c Fri Jan 1 02:03:13 1904
@@ -159,7 +159,7 @@ chat_start(struct session *s, char *with_node)
else
s->chatting_with_node[0] = '\0';
- session_log(s, "Entered chat with %s", with_node[0] ? with_node :
+ session_logf(s, "Entered chat with %s", with_node[0] ? with_node :
"everyone");
session_printf(s,
@@ -235,7 +235,7 @@ chat_start(struct session *s, char *with_node)
xfree(&input);
}
- session_log(s, "Left chat with %s", with_node[0] ? with_node :
+ session_logf(s, "Left chat with %s", with_node[0] ? with_node :
"everyone");
snprintf(chat_tbuf, sizeof(chat_tbuf),
--- console.c Sat Aug 13 14:17:38 2022
+++ console.c Fri Jan 1 02:06:39 1904
@@ -337,7 +337,7 @@ void
console_close_from_session(struct session *session)
{
struct console *console = (struct console *)session->cookie;
- session_log(session, "Closing console session");
+ session_logf(session, "Closing console session");
destroy_focusable(console->focusable);
xfree(&console);
}
--- folder.c Wed Aug 3 14:15:05 2022
+++ folder.c Fri Jan 1 02:03:54 1904
@@ -389,11 +389,11 @@ folder_upload(struct session *s, struct folder *folder
ZInit(zs);
s->transferring_file = true;
- session_log(s, "[%s] Uploading file to %s", folder->name, upload_path);
+ session_logf(s, "[%s] Uploading file to %s", folder->name, upload_path);
for (;;) {
if (ZHaveTimedOut(zs)) {
ZTimeOutProc(zs);
- session_log(s, "[%s] Transfer timed out, canceling",
+ session_logf(s, "[%s] Transfer timed out, canceling",
folder->name);
break;
}
@@ -419,7 +419,7 @@ folder_upload(struct session *s, struct folder *folder
session_printf(s, "\r\n\r\n");
if (stat(upload_path, &sb) != 0) {
- session_log(s, "[%s] Failed receiving upload, no temp file",
+ session_logf(s, "[%s] Failed receiving upload, no temp file",
folder->name);
session_printf(s, "Failed receiving file, aborting.\r\n");
session_pause_return(s, CONTROL_C, "to continue...");
@@ -430,7 +430,7 @@ folder_upload(struct session *s, struct folder *folder
}
if (sb.st_size != zs->file_size) {
- session_log(s, "[%s] Received uploaded file of size %ld but "
+ session_logf(s, "[%s] Received uploaded file of size %ld but "
"supposed to be %ld, canceling", folder->name, sb.st_size,
zs->file_size);
session_printf(s,
@@ -453,7 +453,7 @@ folder_upload(struct session *s, struct folder *folder
strlcpy(file.filename, zs->file_name, sizeof(file.filename));
file.size = sb.st_size;
- session_log(s, "[%s] Received uploaded file %s of size %ld",
+ session_logf(s, "[%s] Received uploaded file %s of size %ld",
folder->name, file.filename, file.size);
/* this will fclose and free zs */
@@ -588,7 +588,7 @@ file_upload_annotate:
session_flush(s);
if (folder_file_save(folder, &file, upload_path)) {
- session_log(s, "[%s] Saved file %s", folder->name,
+ session_logf(s, "[%s] Saved file %s", folder->name,
file.filename);
session_printf(s, "done\r\n");
session_flush(s);
@@ -627,10 +627,10 @@ file_upload_cancel:
error = FSDelete(upload_path, 0);
PtoCstr(upload_path);
if (error) {
- session_log(s, "[%s] Failed deleting temporary uploaded "
+ session_logf(s, "[%s] Failed deleting temporary uploaded "
"file %s: %d", folder->name, upload_path, error);
} else {
- session_log(s, "[%s] Canceled upload, deleted temp file %s",
+ session_logf(s, "[%s] Canceled upload, deleted temp file %s",
folder->name, upload_path);
}
}
@@ -729,7 +729,7 @@ folder_file_view(struct session *s, struct folder *fol
file.filename);
fp = fopen(path, "rb");
if (!fp) {
- session_log(s, "[%s] Failed opening file %s",
+ session_logf(s, "[%s] Failed opening file %s",
folder->name, path);
session_printf(s,
"{{B}}Error:{{/B}} Failed opening file\r\n");
@@ -742,12 +742,12 @@ folder_file_view(struct session *s, struct folder *fol
ZInit(zs);
s->transferring_file = true;
- session_log(s, "[%s] Downloading file %s", folder->name,
+ session_logf(s, "[%s] Downloading file %s", folder->name,
file.filename);
for (;;) {
if (ZHaveTimedOut(zs)) {
ZTimeOutProc(zs);
- session_log(s, "[%s] Transfer timed out, canceling",
+ session_logf(s, "[%s] Transfer timed out, canceling",
folder->name);
break;
}
@@ -976,14 +976,14 @@ folder_delete_file(struct session *s, struct folder *f
PtoCstr(path);
if (ret != 0)
- session_log(s, "[%s] Failed deleting %s: %d", folder->name,
+ session_logf(s, "[%s] Failed deleting %s: %d", folder->name,
path, ret);
xfree(&path);
if (file->notes != NULL)
xfree(&file->notes);
- session_log(s, "[%s] Deleted file %s (%ld)", folder->name,
+ session_logf(s, "[%s] Deleted file %s (%ld)", folder->name,
file->filename, file->id);
}
--- logger.c Thu Aug 11 16:05:11 2022
+++ logger.c Fri Jan 1 23:14:03 1904
@@ -29,17 +29,20 @@ void logger_update(struct focusable *focusable, EventR
void logger_resume(struct focusable *focusable, EventRecord *event);
void logger_close(struct focusable *focusable, EventRecord *event);
bool logger_quit(struct focusable *focusable);
+void logger_flush_buffer(struct logger *logger);
struct logger *
logger_init(void)
{
struct focusable *focusable;
struct logger *logger;
- char title[64];
Rect bounds = { 0 };
short padding = 5;
logger = xmalloczero(sizeof(struct logger), "logger");
+ logger->buffered_logs = xmalloc(LOGGER_BUFFERED_LOG_SIZE,
+ "logger buffer");
+ logger->autoflush = true;
bounds.left = padding;
bounds.top = ((screenBits.bounds.bottom -
@@ -47,8 +50,7 @@ logger_init(void)
bounds.right = screenBits.bounds.right - padding - 1;
bounds.bottom = screenBits.bounds.bottom - padding - 1;
- snprintf(title, sizeof(title), "%s", db->config.name);
- logger->win = NewWindow(0L, &bounds, CtoPstr(title), false,
+ logger->win = NewWindow(0L, &bounds, "\p", false,
documentProc, (WindowPtr)-1L, true, 0);
if (!logger->win)
panic("Can't create logger window");
@@ -131,7 +133,11 @@ logger_resume(struct focusable *focusable, EventRecord
void
logger_close(struct focusable *focusable, EventRecord *event)
{
+ struct logger *logger = (struct logger *)(focusable->cookie);
+
destroy_focusable(focusable);
+ xfree(&logger->buffered_logs);
+ xfree(&logger);
}
void
@@ -274,10 +280,7 @@ size_t
logger_vprintf(struct logger *logger, const char *format, va_list ap)
{
static char buf[600];
- RgnHandle savergn;
- Rect zerorect = { 0, 0, 0, 0 };
- GrafPtr old_port;
- size_t len;
+ ssize_t left, len;
time_t now = Time;
short line_height = 0;
@@ -285,30 +288,46 @@ logger_vprintf(struct logger *logger, const char *form
return 0;
blanker_unblank();
- len = 0;
- if ((*(logger->messages_te))->teLength > 0) {
- buf[0] = '\r';
- len++;
- }
-
- len += strftime(buf + len, sizeof(buf) - len, "[%H:%M:%S] ",
- localtime(&now));
-
+ len = strftime(buf, sizeof(buf), "\r[%H:%M:%S] ", localtime(&now));
len += vsnprintf(buf + len, sizeof(buf) - len, format, ap);
-
+ if (len > sizeof(buf))
+ len = sizeof(buf);
+
while (buf[len - 1] == '\r')
len--;
- line_height = LOGGER_FONT_SIZE + 3;
+ if (logger->buffered_logs_len + len > LOGGER_BUFFERED_LOG_SIZE)
+ logger_flush_buffer(logger);
+
+ len = strlcat(logger->buffered_logs, buf, LOGGER_BUFFERED_LOG_SIZE);
+ logger->buffered_logs_len = MIN(len, LOGGER_BUFFERED_LOG_SIZE);
- HLock(logger->messages_te);
+ if (logger->autoflush)
+ logger_flush_buffer(logger);
+}
+
+void
+logger_flush_buffer(struct logger *logger)
+{
+ RgnHandle savergn;
+ Rect zerorect = { 0, 0, 0, 0 };
+ GrafPtr old_port;
+ short line_height = 0;
+ char *buf;
+ if (logger->buffered_logs_len == 0)
+ return;
+
+ line_height = LOGGER_FONT_SIZE + 3;
+
GetPort(&old_port);
SetPort(logger->win);
/* check for TE overflow */
+ HLock(logger->messages_te);
+
/* too many lines */
if ((*(logger->messages_te))->nLines >=
(nitems((*(logger->messages_te))->lineStarts) - 10))
@@ -347,7 +366,15 @@ te_overflow:
no_overflow:
TESetSelect(SHRT_MAX, SHRT_MAX, logger->messages_te);
- TEInsert(buf, len, logger->messages_te);
+
+ buf = logger->buffered_logs;
+ if ((*(logger->messages_te))->teLength == 0) {
+ /* skip leading \r */
+ logger->buffered_logs_len--;
+ buf++;
+ }
+
+ TEInsert(buf, logger->buffered_logs_len, logger->messages_te);
TEPinScroll(0, -INT_MAX, logger->messages_te);
SetCtlValue(logger->messages_scroller,
@@ -357,6 +384,7 @@ no_overflow:
HUnlock(logger->messages_te);
SetPort(old_port);
-
- return len;
+
+ logger->buffered_logs_len = 0;
+ logger->buffered_logs[0] = '\0';
}
--- logger.h Thu Aug 11 09:15:21 2022
+++ logger.h Fri Jan 1 12:46:48 1904
@@ -29,6 +29,10 @@ struct logger {
WindowPtr win;
TEHandle messages_te;
ControlHandle messages_scroller;
+ bool autoflush;
+ char *buffered_logs;
+#define LOGGER_BUFFERED_LOG_SIZE 1024
+ size_t buffered_logs_len;
};
struct logger * logger_init(void);
--- serial.c Sat Aug 13 13:15:00 2022
+++ serial.c Fri Jan 1 02:06:20 1904
@@ -499,6 +499,6 @@ serial_output(struct session *session)
void
serial_close(struct session *session)
{
- session_log(session, "Closing serial session");
+ session_logf(session, "Closing serial session");
serial_reset();
}
--- session.c Sat Aug 13 14:15:58 2022
+++ session.c Fri Jan 1 12:47:29 1904
@@ -41,8 +41,11 @@ short nsessions = 0;
struct session_tally session_today_tally = { 0 };
+static char session_log_tbuf[256];
+
void session_run(struct uthread *uthread, void *arg);
short session_login(struct session *s);
+size_t session_log(struct session *session, const char *str);
size_t session_vprintf(struct session *session, const char *format,
va_list ap);
size_t session_expand_var(struct session *session, char *ivar, char **ret,
@@ -389,22 +392,44 @@ session_flush(struct session *session)
}
size_t
-session_log(struct session *session, const char *format, ...)
+session_log(struct session *session, const char *str)
{
- static char session_log_tbuf[256];
+ return logger_printf(logger, "[%s] [%s] %s", session->node,
+ session->logged_in ?
+ (session->user ? session->user->username : "guest") : "-",
+ str);
+}
+
+size_t
+session_logf(struct session *session, const char *format, ...)
+{
va_list ap;
va_start(ap, format);
vsnprintf(session_log_tbuf, sizeof(session_log_tbuf), format, ap);
va_end(ap);
- return logger_printf(logger, "[%s] [%s] %s", session->node,
- session->logged_in ?
- (session->user ? session->user->username : "guest") : "-",
- session_log_tbuf);
+ return session_log(session, session_log_tbuf);
}
size_t
+session_logf_buffered(struct session *session, const char *format, ...)
+{
+ va_list ap;
+ size_t ret;
+
+ va_start(ap, format);
+ vsnprintf(session_log_tbuf, sizeof(session_log_tbuf), format, ap);
+ va_end(ap);
+
+ logger->autoflush = false;
+ ret = session_log(session, session_log_tbuf);
+ logger->autoflush = true;
+
+ return ret;
+}
+
+size_t
session_output(struct session *session, const char *str, size_t len)
{
size_t chunk, olen = len, stroff = 0;
@@ -686,9 +711,9 @@ done_consuming:
idled_out:
if (session->logged_in)
- session_log(session, "Idle too long, logging out");
+ session_logf(session, "Idle too long, logging out");
else
- session_log(session, "Took too long to login, disconnecting");
+ session_logf(session, "Took too long to login, disconnecting");
session_printf(session,
"\r\n\r\nYou have been idle too long, goodbye.\r\n\r\n");
session_flush(session);
@@ -892,14 +917,14 @@ session_login(struct session *s)
}
if (strcmp(username, GUEST_USERNAME) == 0) {
- session_log(s, "Successful guest login in as %s", username);
+ session_logf(s, "Successful guest login in as %s", username);
xfree(&username);
return AUTH_USER_GUEST;
}
if ((strcmp(username, "signup") == 0 ||
strcmp(username, "new") == 0) && db->config.open_signup) {
- session_log(s, "Successful guest signup login in as %s",
+ session_logf(s, "Successful guest signup login in as %s",
username);
xfree(&username);
return AUTH_USER_SIGNUP;
@@ -908,7 +933,7 @@ session_login(struct session *s)
user = user_find_by_username(username);
if (!user && user_username_is_banned(username)) {
- session_log(s, "Attempted login as banned username %s",
+ session_logf(s, "Attempted login as banned username %s",
username);
s->ban_node_source = 1;
goto login_bail;
@@ -918,7 +943,7 @@ session_login(struct session *s)
if (user) {
xfree(&username);
s->user = user;
- session_log(s, "Automatically logged in as %s",
+ session_logf(s, "Automatically logged in as %s",
s->autologin_username);
return AUTH_USER_OK;
}
@@ -941,15 +966,15 @@ session_login(struct session *s)
if (user->is_enabled)
s->user = user;
else
- session_log(s, "Successful password login for %s but "
+ session_logf(s, "Successful password login for %s but "
"account is disabled", user->username);
} else
- session_log(s, "Failed password login for %s",
+ session_logf(s, "Failed password login for %s",
user->username);
} else {
/* kill some time */
SHA256Data((const u_int8_t *)password, strlen(password), junk);
- session_log(s, "Failed password login for invalid user %s",
+ session_logf(s, "Failed password login for invalid user %s",
username);
}
@@ -964,7 +989,7 @@ session_login(struct session *s)
password = NULL;
if (s->user) {
- session_log(s, "Successful password login for user %s",
+ session_logf(s, "Successful password login for user %s",
s->user->username);
return AUTH_USER_OK;
}
@@ -984,7 +1009,7 @@ login_bail:
xfree(&password);
if (!s->ban_node_source) {
if (session_idled_out(s)) {
- session_log(s, "Login timed out after %d seconds",
+ session_logf(s, "Login timed out after %d seconds",
db->config.max_login_seconds);
session_printf(s, "\r\nLogin timed out after %d seconds\r\n",
db->config.max_login_seconds);
--- session.h Tue Jul 19 15:29:07 2022
+++ session.h Fri Jan 1 12:52:42 1904
@@ -129,7 +129,8 @@ bool session_wait_for_chars(struct session *session,
unsigned short session_input_char(struct session *session);
void session_clear_input(struct session *session);
void session_flush(struct session *session);
-size_t session_log(struct session *session, const char *format, ...);
+size_t session_logf(struct session *session, const char *format, ...);
+size_t session_logf_buffered(struct session *session, const char *format, ...);
size_t session_output(struct session *session, const char *str, size_t len);
size_t session_printf(struct session *session, const char *format, ...);
size_t session_output_view_or_printf(struct session *session, short id,
--- signup.c Sun Jul 31 21:34:15 2022
+++ signup.c Fri Jan 1 02:06:08 1904
@@ -32,13 +32,13 @@ signup(struct session *s)
char *username = NULL, *password = NULL, *password_confirm = NULL,
*error = NULL;
- session_log(s, "Signing up for an account");
+ session_logf(s, "Signing up for an account");
session_printf(s, "{{B}}Create Account{{/B}} "
"(^C to cancel)\r\n"
"{{B}}----------------------------{{/B}}\r\n");
session_output_view_or_printf(s, DB_TEXT_SIGNUP_ID,
- "[ Signup instructions missing ]");
+ "[ Signup instructions missing ]\r\n\r\n");
session_flush(s);
for (;;) {
@@ -109,7 +109,7 @@ signup(struct session *s)
user_save(user);
user_cache_usernames();
- session_log(s, "New user account created for %s", user->username);
+ session_logf(s, "New user account created for %s", user->username);
signup_done:
if (username != NULL)
--- sysop.c Mon Aug 1 12:54:18 2022
+++ sysop.c Fri Jan 1 02:06:04 1904
@@ -50,7 +50,7 @@ sysop_menu(struct session *s)
if (!s->user || !s->user->is_sysop)
return;
- session_log(s, "Entered sysop menu");
+ session_logf(s, "Entered sysop menu");
while (!done && !s->ending) {
c = session_menu(s, "Sysop Menu", "Sysop", opts, nitems(opts),
@@ -102,7 +102,7 @@ sysop_edit_settings(struct session *s)
db_config_save(db);
memcpy(&db->config, &old_config, sizeof(db->config));
- session_log(s, "Changed BBS settings");
+ session_logf(s, "Changed BBS settings");
session_printf(s, "Successfully saved changes to BBS Settings, "
"restart to take effect\r\n");
xfree(&new_config);
@@ -170,7 +170,7 @@ sysop_edit_boards(struct session *s)
bile_close(new_board_bile);
db_cache_boards(db);
- session_log(s, "Created new board %ld: %s", new_board->id,
+ session_logf(s, "Created new board %ld: %s", new_board->id,
new_board->name);
xfree(&board);
xfree(&new_board);
@@ -211,7 +211,7 @@ sysop_edit_boards(struct session *s)
panic("save of board failed: %d", bile_error(db->bile));
xfree(&data);
- session_log(s, "Saved changes to board %ld: %s",
+ session_logf(s, "Saved changes to board %ld: %s",
new_board->id, new_board->name);
xfree(&new_board);
break;
@@ -293,7 +293,7 @@ sysop_edit_folders(struct session *s)
bile_close(new_folder_bile);
db_cache_folders(db);
- session_log(s, "Created new folder %ld: %s", new_folder->id,
+ session_logf(s, "Created new folder %ld: %s", new_folder->id,
new_folder->name);
xfree(&folder);
xfree(&new_folder);
@@ -335,7 +335,7 @@ sysop_edit_folders(struct session *s)
bile_error(db->bile));
xfree(&data);
- session_log(s, "Saved changes to folder %ld: %s",
+ session_logf(s, "Saved changes to folder %ld: %s",
new_folder->id, new_folder->name);
xfree(&new_folder);
break;
--- telnet.c Thu Aug 11 09:17:23 2022
+++ telnet.c Fri Jan 1 12:55:44 1904
@@ -422,7 +422,7 @@ telnet_input(struct session *session)
(Ptr)(session->ibuf + session->ibufoff + session->ibuflen), &rlen,
nil, nil, false);
if (error) {
- session_log(session, "TCP read failed (%d), closing connection",
+ session_logf(session, "TCP read failed (%d), closing connection",
error);
session->ending = 1;
return 0;
@@ -440,7 +440,7 @@ telnet_input(struct session *session)
error = _TCPRcv(&node->rcv_pb, node->stream,
(Ptr)(node->ibuf + node->ibuflen), &rlen, nil, nil, false);
if (error) {
- session_log(session, "TCP read failed (%d), closing connection",
+ session_logf(session, "TCP read failed (%d), closing connection",
error);
session->ending = 1;
return 0;
@@ -529,7 +529,7 @@ telnet_input(struct session *session)
if (node->iac_sb[sboff] == 255)
sboff++;
session->terminal_lines |= node->iac_sb[sboff++];
- session_log(session, "IAC NAWS %d, %d",
+ session_logf_buffered(session, "IAC NAWS %d, %d",
session->terminal_columns, session->terminal_lines);
break;
case IAC_TTYPE:
@@ -538,16 +538,16 @@ telnet_input(struct session *session)
strlcpy(session->terminal_type,
(char *)&node->iac_sb + 2,
sizeof(session->terminal_type));
-
- session_log(session, "IAC TTYPE IS %s",
+ session_logf_buffered(session, "IAC TTYPE IS %s",
session->terminal_type);
for (j = 0; vt100_terms[j] != NULL; j++) {
if (strncasecmp(session->terminal_type,
vt100_terms[j], strlen(vt100_terms[j])) == 0) {
- session_log(session, "Activating vt100 ANSI "
- "support for matching %s", vt100_terms[j]);
- session->vt100 = 1;
+ session_logf_buffered(session,
+ "Activating vt100 ANSI support for "
+ "matching %s", vt100_terms[j]);
+ session->vt100 = true;
break;
}
}
@@ -566,7 +566,7 @@ telnet_input(struct session *session)
node->iac_sb[j] == 0 || node->iac_sb[j] == 3) {
v[l] = '\0';
if (l) {
- session_log(session,
+ session_logf_buffered(session,
"NEWENV \"%s\" = \"%s\"", k, v);
if (node->from_trusted_proxy &&
@@ -599,7 +599,7 @@ telnet_input(struct session *session)
/* IAC SB TSPEED IS 38400,19200 SE */
node->iac_sb[node->sb_len - 1] = '\0';
- session_log(session, "IAC TSPEED IS %s",
+ session_logf_buffered(session, "IAC TSPEED IS %s",
node->iac_sb + 2);
for (j = 2; j < node->sb_len; j++) {
@@ -629,7 +629,7 @@ telnet_input(struct session *session)
/* IAC overflow */
node->iac_state = TELNET_IAC_STATE_IDLE;
node->sb_len = 0;
- session_log(session, "IAC SB overflow");
+ session_logf(session, "IAC SB overflow");
}
}
break;
@@ -825,7 +825,7 @@ telnet_close(struct session *session)
if (session->ban_node_source && !node->from_trusted_proxy &&
db->config.trusted_proxy_ip != 0 &&
db->config.trusted_proxy_udp_port != 0) {
- session_log(session, "Closing telnet connection from %s and "
+ session_logf(session, "Closing telnet connection from %s and "
"banning IP", node->ip_s);
tmp = (unsigned char *)&node->ip;
@@ -840,10 +840,10 @@ telnet_close(struct session *session)
db->config.trusted_proxy_ip,
db->config.trusted_proxy_udp_port, NULL, NULL, false);
if (error)
- session_log(session, "Failed sending IP ban UDP packet: %d",
+ session_logf(session, "Failed sending IP ban UDP packet: %d",
error);
} else {
- session_log(session, "Closing telnet connection from %s",
+ session_logf(session, "Closing telnet connection from %s",
node->ip_s);
error = _TCPClose(&telnet_exit_pb, node->stream, nil, nil, false);
--- user.c Mon Aug 1 09:59:16 2022
+++ user.c Fri Jan 1 02:05:33 1904
@@ -359,11 +359,11 @@ user_change_password(struct session *s, struct user *u
user_save(user);
if (strcmp(s->user->username, user->username) == 0) {
- session_log(s, "User changed password");
+ session_logf(s, "User changed password");
session_printf(s, "{{B}}Your password has been "
"changed{{/B}}\r\n");
} else {
- session_log(s, "User %s changed password for %s",
+ session_logf(s, "User %s changed password for %s",
s->user->username, user->username);
session_printf(s, "{{B}}Password has been "
"changed{{/B}}\r\n");
--- user_settings.c Sat Aug 13 14:08:07 2022
+++ user_settings.c Fri Jan 1 02:05:42 1904
@@ -115,7 +115,7 @@ get_terminal_size:
s->terminal_columns = cols;
s->terminal_lines = lines;
- session_log(s, "Changed terminal size to %dx%d", cols, lines);
+ session_logf(s, "Changed terminal size to %dx%d", cols, lines);
}
void
@@ -159,7 +159,7 @@ user_settings_username(struct session *s)
continue;
}
- session_log(s, "User changed username from %s to %s",
+ session_logf(s, "User changed username from %s to %s",
s->user->username, username);
strlcpy(s->user->username, username, sizeof(s->user->username));
user_save(s->user);
@@ -187,7 +187,7 @@ user_settings_menu(struct session *s)
bool show_help = true;
bool done = false;
- session_log(s, "User settings menu");
+ session_logf(s, "User settings menu");
while (!done) {
c = session_menu(s, "Settings", "Settings", opts, nitems(opts),