mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-25 21:55:25 +02:00
Make logging cost free when there is no output target (#12247)
The logging streams now do almost no work when there is no output target for them. For example, if LL_VERBOSE has no output targets, then `verbosestream << x` will return a StreamProxy with a null target. Any further `<<` operations applied to it will do nothing.
This commit is contained in:
@@ -198,7 +198,7 @@ void UDPSocket::Send(const Address &destination, const void *data, int size)
|
||||
if (socket_enable_debug_output) {
|
||||
// Print packet destination and size
|
||||
dstream << (int)m_handle << " -> ";
|
||||
destination.print(&dstream);
|
||||
destination.print(dstream);
|
||||
dstream << ", size=" << size;
|
||||
|
||||
// Print packet contents
|
||||
@@ -295,7 +295,7 @@ int UDPSocket::Receive(Address &sender, void *data, int size)
|
||||
if (socket_enable_debug_output) {
|
||||
// Print packet sender and size
|
||||
dstream << (int)m_handle << " <- ";
|
||||
sender.print(&dstream);
|
||||
sender.print(dstream);
|
||||
dstream << ", size=" << received;
|
||||
|
||||
// Print packet contents
|
||||
|
||||
Reference in New Issue
Block a user