mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00: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:
parent
ae7664597e
commit
0704ca0550
14 changed files with 336 additions and 192 deletions
|
@ -32,22 +32,18 @@ namespace con
|
|||
/* defines used for debugging and profiling */
|
||||
/******************************************************************************/
|
||||
#ifdef NDEBUG
|
||||
#define LOG(a) a
|
||||
#define PROFILE(a)
|
||||
#undef DEBUG_CONNECTION_KBPS
|
||||
#else
|
||||
/* this mutex is used to achieve log message consistency */
|
||||
std::mutex log_conthread_mutex;
|
||||
#define LOG(a) \
|
||||
{ \
|
||||
MutexAutoLock loglock(log_conthread_mutex); \
|
||||
a; \
|
||||
}
|
||||
#define PROFILE(a) a
|
||||
//#define DEBUG_CONNECTION_KBPS
|
||||
#undef DEBUG_CONNECTION_KBPS
|
||||
#endif
|
||||
|
||||
// TODO: Clean this up.
|
||||
#define LOG(a) a
|
||||
|
||||
#define WINDOW_SIZE 5
|
||||
|
||||
static session_t readPeerId(const u8 *packetdata)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue