jcs
/subtext
/amendments
/91
logger: Minor logging tweaks
jcs made amendment 91 over 2 years ago
--- logger.c Thu Mar 31 15:04:33 2022
+++ logger.c Thu Mar 31 15:59:05 2022
@@ -36,7 +36,7 @@ logger_init(void)
struct logger *logger;
char title[64];
Rect bounds = { 0 };
- short padding = 10;
+ short padding = 5;
logger = xmalloczero(sizeof(struct logger));
@@ -71,6 +71,8 @@ logger_init(void)
add_focusable(focusable);
logger->focusable = focusable;
+ DrawControls(logger->win);
+
return logger;
}
@@ -92,7 +94,7 @@ logger_layout(struct logger *logger, bool init, Rect *
bounds.top = -1;
bounds.right = win_bounds.right - win_bounds.left;
bounds.bottom = win_bounds.bottom - win_bounds.top;
- bounds.left = bounds.right - SCROLLBAR_WIDTH;
+ bounds.left = bounds.right;
if (init)
logger->messages_scroller = NewControl(logger->win, &bounds,
"\p", true, 1, 1, 1, scrollBarProc, 0L);
@@ -250,11 +252,6 @@ logger_printf(struct logger *logger, const char *forma
va_start(argptr, format);
len += vsnprintf(buf + len, sizeof(buf) - len, format, argptr);
va_end(argptr);
-
- if (buf[len - 1] == '\r') {
- buf[len - 1] = '\0';
- len--;
- }
line_height = LOGGER_FONT_SIZE + 3;
--- serial.c Thu Mar 31 15:06:28 2022
+++ serial.c Thu Mar 31 15:59:33 2022
@@ -224,8 +224,6 @@ maybe_read:
FSRead(serial_in_refnum, &len,
serial_input_buf + serial_input_buf_len);
serial_input_buf[serial_input_buf_len + len] = '\0';
- logger_printf(logger, "[modem] Read: %s",
- serial_input_buf + serial_input_buf_len);
serial_input_buf_len += len;
}
}
@@ -256,6 +254,8 @@ find_line:
if (serial_cur_line[0] == '\0')
goto find_line;
+ logger_printf(logger, "[modem] Read: %s", serial_cur_line);
+
return (char *)&serial_cur_line;
}
}
@@ -277,6 +277,7 @@ void
serial_atexit(void)
{
serial_hangup();
+ serial_printf("ATZ\r");
SerSetBuf(serial_in_refnum, (Ptr)&serial_input_internal_buf, 0);
if (serial_in_refnum)
--- session.c Thu Mar 31 15:25:52 2022
+++ session.c Thu Mar 31 15:51:48 2022
@@ -62,8 +62,6 @@ session_create(char *node, char *via, struct node_func
sessions = xreallocarray(sessions, nsessions, sizeof(struct session));
sessions[nsessions - 1] = session;
- logger_printf(logger, "[%s] New session via %s", node, via);
-
return session;
}
@@ -211,7 +209,8 @@ session_close(struct session *session)
/* finalize session log */
session->log.logged_off_at = Time;
- logger_printf(logger, "[%s] Closing session", session->node);
+ logger_printf(logger, "[%s] Closing session for user %s",
+ session->node, session->user ? session->user->username : "guest");
if (bile_write(db->sessions_bile, SL_LOG_RTYPE, session->log.id,
&session->log, sizeof(session->log)) != sizeof(session->log))
--- telnet.c Thu Mar 31 15:38:37 2022
+++ telnet.c Thu Mar 31 15:54:02 2022
@@ -89,6 +89,7 @@ enum {
struct telnet_node {
short id;
short state;
+ char ip_s[20];
TCPiopb rcv_pb, send_pb, listen_pb;
StreamPtr stream;
wdsEntry tcp_wds[2];
@@ -112,6 +113,7 @@ struct telnet_node *telnet_listener_node = NULL;
short telnet_local_port;
TCPiopb telnet_exit_pb;
TCPStatusPB telnet_status_pb;
+bool did_initial_log = false;
void telnet_setup(struct session *session);
short telnet_process_input(struct session *session);
@@ -194,10 +196,14 @@ telnet_idle(void)
panic("TCPGetOurIP failed: %d", error);
port = db->config.telnet_port;
- long2ip(ip, ip_s);
- logger_printf(logger, "[telnet] Listening on %s:%d", ip_s,
- port);
+ if (!did_initial_log) {
+ long2ip(ip, ip_s);
+ logger_printf(logger, "[telnet] Listening on %s:%d", ip_s,
+ port);
+ did_initial_log = true;
+ }
+
error = _TCPPassiveOpen(&node->listen_pb, node->stream, nil,
nil, &ip, &port, nil, nil, true);
if (error)
@@ -220,13 +226,12 @@ telnet_idle(void)
if (telnet_status_pb.connectionState ==
ConnectionStateEstablished) {
char tty[7];
- char ip_s[20];
sprintf(tty, "ttyt%d", n);
- long2ip(telnet_status_pb.remoteHost, ip_s);
+ long2ip(telnet_status_pb.remoteHost, node->ip_s);
logger_printf(logger, "[%s] New telnet connection from %s",
- tty, ip_s);
+ tty, node->ip_s);
node->state = TELNET_PB_STATE_CONNECTED;
node->session = session_create(tty, "telnet",
@@ -599,8 +604,8 @@ telnet_close(struct session *session)
struct telnet_node *node = (struct telnet_node *)session->cookie;
short error;
- logger_printf(logger, "[%s] Closing telnet connection",
- session->node);
+ logger_printf(logger, "[%s] Closing telnet connection from %s",
+ session->node, node->ip_s);
error = _TCPClose(&telnet_exit_pb, node->stream, nil, nil, false);
/* TODO: allow some time to fully close? */