Skip to content

Commit

Permalink
Merge pull request #1317 from contour-terminal/improvement/conpty-log…
Browse files Browse the repository at this point in the history
…ging

add logging to ConPTY I/O
  • Loading branch information
christianparpart committed Oct 29, 2023
2 parents a476e7f + 669fac8 commit 3c6c38e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/vtpty/ConPty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ Pty::ReadResult ConPty::read(crispy::buffer_object<char>& buffer,
if (!ReadFile(_input, buffer.hotEnd(), n, &nread, nullptr))
return nullopt;

if (ptyInLog)
ptyInLog()("{} received: \"{}\"", "master", crispy::escape(buffer.hotEnd(), buffer.hotEnd() + nread));

return { tuple { string_view { buffer.hotEnd(), nread }, false } };
}

Expand All @@ -166,9 +169,15 @@ int ConPty::write(std::string_view data)

DWORD nwritten {};
if (WriteFile(_output, buf, static_cast<DWORD>(size), &nwritten, nullptr))
{
ptyOutLog()("Sending bytes: \"{}\"", crispy::escape(data.data(), data.data() + nwritten));
return static_cast<int>(nwritten);
}
else
{
ptyOutLog()("PTY write of {} bytes failed.\n", size);
return -1;
}
}

PageSize ConPty::pageSize() const noexcept
Expand Down

0 comments on commit 3c6c38e

Please sign in to comment.