Skip to main content

ClientLogSender

A class in Root.Township, the global namespace.

Streams the server's console log to a remote console client over TCP. One is made per ClientHandler connection. Server.

Constructors​

MemberWhat it is
ClientLogSender()Creates a ClientLogSender with default values.

Fields​

6 private and internal fields
MemberWhat it is
private bool isActiveFalse once Close is called, which ends the send thread.
private ConcurrentQueue<LogEventInfo> logEventsThread-safe queue of log events waiting to be sent.
private static Logger loggerNLog logger for this class.
private Socket logSenderThe accepted socket logs are sent on. The listener is on port 1759.
private ManualResetEvent receivedEventSignal that wakes the send thread when a log is queued.
private byte[] sendBuffer64 KB buffer each log event is serialized into before sending.

Methods​

MemberWhat it is
void Close()Stops the send thread, unhooks from the console log target and closes the socket.
4 private and internal methods
MemberWhat it is
private void HandleConsoleLog(LogEventInfo logEvent)Queues a log event from ServerConsoleLogTarget.LogSentRaw and wakes the send thread.
private void ProcessLogs()Background thread loop that waits for queued log events and sends them all.
private void SendLogToClient(LogEventInfo log)Serializes one log event and sends it on the accepted socket. Errors are ignored.
private void StartSendingLogs(IAsyncResult result)Accept callback: keeps the accepted socket and closes the listener.

Used in​

Members of other types that take, return or hold a ClientLogSender: