Log size of output buffer as well.

This commit is contained in:
nicm 2017-02-08 08:54:45 +00:00
parent 9cc02d1498
commit cb80901d33

16
tty.c
View File

@ -439,32 +439,36 @@ tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a,
void void
tty_puts(struct tty *tty, const char *s) tty_puts(struct tty *tty, const char *s)
{ {
size_t size = EVBUFFER_LENGTH(tty->event->output);
if (*s == '\0') if (*s == '\0')
return; return;
bufferevent_write(tty->event, s, strlen(s)); bufferevent_write(tty->event, s, strlen(s));
log_debug("%s (%zu): %s", tty->path, size, s);
if (tty_log_fd != -1) if (tty_log_fd != -1)
write(tty_log_fd, s, strlen(s)); write(tty_log_fd, s, strlen(s));
log_debug("%s: %s", tty->path, s);
} }
void void
tty_putc(struct tty *tty, u_char ch) tty_putc(struct tty *tty, u_char ch)
{ {
size_t size = EVBUFFER_LENGTH(tty->event->output);
const char *acs; const char *acs;
if (tty->cell.attr & GRID_ATTR_CHARSET) { if (tty->cell.attr & GRID_ATTR_CHARSET) {
acs = tty_acs_get(tty, ch); acs = tty_acs_get(tty, ch);
if (acs != NULL) { if (acs != NULL) {
bufferevent_write(tty->event, acs, strlen(acs)); bufferevent_write(tty->event, acs, strlen(acs));
log_debug("%s: %s", tty->path, acs); log_debug("%s (%zu): %s", tty->path, size, acs);
} else { } else {
bufferevent_write(tty->event, &ch, 1); bufferevent_write(tty->event, &ch, 1);
log_debug("%s: %c", tty->path, ch); log_debug("%s (%zu): %c", tty->path, size, ch);
} }
} else { } else {
bufferevent_write(tty->event, &ch, 1); bufferevent_write(tty->event, &ch, 1);
log_debug("%s: %c", tty->path, ch); log_debug("%s (%zu): %c", tty->path, size, ch);
} }
if (ch >= 0x20 && ch != 0x7f) { if (ch >= 0x20 && ch != 0x7f) {
@ -491,11 +495,13 @@ tty_putc(struct tty *tty, u_char ch)
void void
tty_putn(struct tty *tty, const void *buf, size_t len, u_int width) tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
{ {
size_t size = EVBUFFER_LENGTH(tty->event->output);
bufferevent_write(tty->event, buf, len); bufferevent_write(tty->event, buf, len);
log_debug("%s (%zu): %.*s", tty->path, size, (int)len, (char *)buf);
if (tty_log_fd != -1) if (tty_log_fd != -1)
write(tty_log_fd, buf, len); write(tty_log_fd, buf, len);
log_debug("%s: %.*s", tty->path, (int)len, (char *)buf);
tty->cx += width; tty->cx += width;
} }