Skip to content

Commit

Permalink
chore: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
obiltschnig committed Nov 27, 2024
1 parent 84e974f commit d55d8b4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions WebTunnel/src/RemotePortForwarder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Poco/BinaryWriter.h"
#include "Poco/MemoryStream.h"
#include "Poco/CountingStream.h"
#include <algorithm>
#include <cstring>


Expand Down Expand Up @@ -160,6 +161,10 @@ void RemotePortForwarder::multiplex(SocketDispatcher& dispatcher, Poco::Net::Str
try
{
n = socket.receiveBytes(buffer.begin() + hn, static_cast<int>(buffer.size() - hn));
if (_logger.trace() && n >= 0)
{
_logger.dump(Poco::format("Received frame from device, channel=%hu, size=%d"s, channel, n), buffer.begin() + hn, (std::min)(n, 256), Poco::Message::PRIO_TRACE);
}
if (n == 0)
{
if (_logger.debug())
Expand Down Expand Up @@ -254,6 +259,10 @@ void RemotePortForwarder::demultiplex(SocketDispatcher& dispatcher, Poco::Net::S
try
{
n = _pWebSocket->receiveFrame(buffer.begin(), static_cast<int>(buffer.size()), wsFlags);
if (_logger.trace() && n >= 0)
{
_logger.dump(Poco::format("Received WebSocket frame, size=%d, flags=%d"s, n, wsFlags), buffer.begin(), (std::min)(n, 256), Poco::Message::PRIO_TRACE);
}
if (n < 0) return;
}
catch (Poco::Exception& exc)
Expand Down Expand Up @@ -390,6 +399,7 @@ void RemotePortForwarder::connect(SocketDispatcher& dispatcher, Poco::Net::Strea
socket.setNoDelay(true);
try
{
_logger.debug("Socket for channel %hu is connected."s, channel);
sendResponse(channel, Protocol::WT_OP_OPEN_CONFIRM, 0);
}
catch (Poco::Exception& exc)
Expand Down

0 comments on commit d55d8b4

Please sign in to comment.