Skip to content

Commit

Permalink
update TweakMe.h with some protection guards
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed Nov 1, 2023
1 parent a54faec commit a3dbd03
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
30 changes: 29 additions & 1 deletion quill/include/quill/TweakMe.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
* QUILL_LOG_LEVEL_ERROR
* QUILL_LOG_LEVEL_CRITICAL
*/
#if !defined(QUILL_ACTIVE_LOG_LEVEL)
// #define QUILL_ACTIVE_LOG_LEVEL QUILL_LOG_LEVEL_TRACE_L3
#endif

/**
* Quill defers formatting to the backend thread. Objects are copied to a queue and formatted
Expand Down Expand Up @@ -67,21 +69,27 @@
* When MODE_UNSAFE is enabled, Quill copies any copy-constructible user-defined types to the queue
* without checks. Tagging or specialization is not required.
*/
#if !defined(QUILL_MODE_UNSAFE)
// #define QUILL_MODE_UNSAFE
#endif

/**
* When QUILL_DISABLE_NON_PREFIXED_MACROS is defined, it removes `LOG_*` macros,
* and only `QUILL_LOG_*` macros are available.
* This is useful if the original macro names collide with an existing logging library.
*/
#if !defined(QUILL_DISABLE_NON_PREFIXED_MACROS)
// #define QUILL_DISABLE_NON_PREFIXED_MACROS
#endif

/**
* When the application doesn't require multiple Logger objects and the root logger is enough,
* define QUILL_ROOT_LOGGER_ONLY to log without passing any Logger* to the macro.
* Example: LOG_INFO("Hello {}", "world");
*/
#if !defined(QUILL_ROOT_LOGGER_ONLY)
// #define QUILL_ROOT_LOGGER_ONLY
#endif

/**
* When QUILL_USE_BOUNDED_QUEUE is defined, a bounded queue is used instead of the default unbounded queue.
Expand All @@ -102,7 +110,9 @@
*
* @see: examples/example_bounded_queue_message_dropping.cpp
*/
#if !defined(QUILL_USE_BOUNDED_QUEUE)
// #define QUILL_USE_BOUNDED_QUEUE
#endif

/**
* Similar to QUILL_USE_BOUNDED_QUEUE but the hot thread will now block instead of dropping messages.
Expand All @@ -113,7 +123,9 @@
*
* @see: examples/example_bounded_queue_blocking.cpp
*/
#if !defined(QUILL_USE_BOUNDED_BLOCKING_QUEUE)
// #define QUILL_USE_BOUNDED_BLOCKING_QUEUE
#endif

/**
* The default unbounded queue stops re-allocating and blocks when it reaches the maximum capacity
Expand All @@ -125,7 +137,9 @@
* For CMake:
* -DCMAKE_CXX_FLAGS:STRING="-DQUILL_USE_UNBOUNDED_NO_MAX_LIMIT_QUEUE"
*/
#if !defined(QUILL_USE_UNBOUNDED_NO_MAX_LIMIT_QUEUE)
// #define QUILL_USE_UNBOUNDED_NO_MAX_LIMIT_QUEUE
#endif

/**
* Similar to QUILL_USE_UNBOUNDED_NO_MAX_LIMIT_QUEUE, but the hot thread will drop messages instead
Expand All @@ -134,14 +148,18 @@
* For CMake:
* -DCMAKE_CXX_FLAGS:STRING="-DQUILL_USE_UNBOUNDED_DROPPING_QUEUE"
*/
#if !defined(QUILL_USE_UNBOUNDED_DROPPING_QUEUE)
// #define QUILL_USE_UNBOUNDED_DROPPING_QUEUE
#endif

/**
* Similar to QUILL_USE_UNBOUNDED_NO_MAX_LIMIT_QUEUE, but the hot thread will block instead
* of allocating additional 2GB queues when the maximum capacity of the unbounded queue is reached.
* This is the default behavior.
*/
#if !defined(QUILL_USE_UNBOUNDED_BLOCKING_QUEUE)
// #define QUILL_USE_UNBOUNDED_BLOCKING_QUEUE
#endif

/**
* Applies to bounded/unbounded blocking queues. When the queue is full, the active thread
Expand All @@ -150,7 +168,9 @@
* For CMake:
* -DCMAKE_CXX_FLAGS:INT="-DBLOCKING_QUEUE_RETRY_INTERVAL_NS=1000"
*/
#if !defined(QUILL_BLOCKING_QUEUE_RETRY_INTERVAL_NS)
// #define QUILL_BLOCKING_QUEUE_RETRY_INTERVAL_NS 800
#endif

/**
* Enables the use of _mm_prefetch, _mm_clflush, and _mm_clflushopt on the ring buffer to improve
Expand All @@ -164,7 +184,9 @@
* or
* target_compile_definitions(<target> PUBLIC -DQUILL_X86ARCH)
*/
#if !defined(QUILL_X86ARCH)
// #define QUILL_X86ARCH
#endif

/**************************************************************************************************/
/* Anything after this point requires the whole library to be recompiled with the desired option. */
Expand All @@ -174,7 +196,9 @@
* Disables features not supported on Windows 2012/2016.
* Also available as CMake option `-DQUILL_NO_THREAD_NAME_SUPPORT:BOOL=ON`
*/
#if !defined(QUILL_NO_THREAD_NAME_SUPPORT)
// #define QUILL_NO_THREAD_NAME_SUPPORT
#endif

/**
* Uses an installed version of the fmt library instead of Quill's bundled copy.
Expand All @@ -188,10 +212,14 @@
* Quill will look for a CMake Target named `fmt`. If the target is not found, it will
* use find_package(fmt REQUIRED), so make sure that the fmt library is installed on your system.
*/
#if !defined(QUILL_FMT_EXTERNAL)
// #define QUILL_FMT_EXTERNAL
#endif

/**
* Disables all exceptions and replaces them with std::abort()
* Also available as CMake option `-DQUILL_NO_EXCEPTIONS=ON`
*/
// #define QUILL_NO_EXCEPTIONS
#if !defined(QUILL_NO_EXCEPTIONS)
// #define QUILL_NO_EXCEPTIONS
#endif
2 changes: 1 addition & 1 deletion quill/include/quill/detail/misc/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#pragma once

#include "quill/TweakMe.h"
#include "quill/detail/misc/Attributes.h"

#include "quill/detail/misc/Attributes.h"
#include "quill/Fmt.h"
#include <functional>
#include <sstream>
Expand Down
3 changes: 2 additions & 1 deletion quill/include/quill/detail/spsc_queue/BoundedQueue.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include "quill/QuillError.h"
#include "quill/TweakMe.h"

#include "quill/QuillError.h"
#include "quill/detail/misc/Attributes.h"
#include "quill/detail/misc/Common.h"
#include "quill/detail/misc/Os.h"
Expand Down

0 comments on commit a3dbd03

Please sign in to comment.