18 #include <shared_mutex>
31 #define QX_LOG_C(category, eVerbosity, ...) _QX_LOG_C(constexpr, category, eVerbosity, ##__VA_ARGS__)
38 #define QX_LOG(eVerbosity, ...) QX_LOG_C(QX_GET_FILE_CATEGORY(), eVerbosity, ##__VA_ARGS__)
46 #define QX_LOG_REF(category, eVerbosity, ...) _QX_LOG_C(, category, eVerbosity, ##__VA_ARGS__)
64 #if QX_CLANG || QX_APPLE_CLANG || QX_GNU
75 verbosity eRuntimeVerbosity = verbosity::detailed;
90 using category_data_map = std::unordered_map<string_view, category_data>;
92 enum class message_necessity_type
95 default_verbosity = 1 << 0,
96 category_verbosity = 1 << 1,
97 one_of_streams_requires = 1 << 2
102 virtual ~
logger() noexcept;
181 verbosity eVerbosity,
182 std::thread::
id threadId,
183 std::chrono::system_clock::time_point messageTime,
185 string_view svFunction,
187 logger_string_pool::item message);
192 virtual
void flush();
197 virtual
void reset() noexcept;
214 verbosity eVerbosity,
215 std::thread::
id threadId,
216 std::chrono::system_clock::time_point messageTime,
218 string_view svFunction,
219 int nLine) const noexcept;
222 logger_string_pool* _get_string_pool() noexcept;
225 QX_PERF_SHARED_MUTEX(m_StreamsMutex);
226 std::vector<logger_sbo> m_Streams;
228 QX_PERF_SHARED_MUTEX(m_RegisteredCategoriesMutex);
229 category_data_map m_RegisteredCategories;
231 logger_string_pool m_StringsPool;
233 string m_sDefaultPattern;
259 inline logger* g_pGlobalLogger =
nullptr;
267 return g_pGlobalLogger ? *g_pGlobalLogger : logger_singleton::get_instance().get_logger();
274 #define _QX_LOG_C(verbosityCheckKeyword, category, eVerbosity, ...) \
277 verbosityCheckKeyword const auto& _category = category; \
278 if verbosityCheckKeyword (eVerbosity >= _category.get_verbosity()) \
280 qx::logger& _logger = qx::get_logger(); \
284 std::this_thread::get_id(), \
285 std::chrono::system_clock::now(), \
287 qx::convert_string_literal<qx::char_type, __FUNCTION__>(), \
289 _QX_MACRO_USER_MESSAGE(_logger._get_string_pool(), __VA_ARGS__)); \
Base class for logger streams.
A category is a class that identifies a particular piece of code. This code can be located in differe...
Wrapper for enumerations to be used as a list of flags.
size_t remove_streams() noexcept
Remove all the streams of the given type.
auto get_streams() noexcept
Get all the streams of the given type.
flags< message_necessity_type > get_message_necessity_type(const category &category, verbosity eVerbosity, std::thread::id threadId, std::chrono::system_clock::time_point messageTime, string_view svFile, string_view svFunction, int nLine) const noexcept
Check if this message will go somewhere.
void add_stream(stream_t stream) noexcept
Add an output stream to the logger.
void register_category(const category &category, category_data data) noexcept
Add custom rules for category.
std::shared_mutex & get_streams_mutex() noexcept
Get streams mutex.
stream_t * get_stream() noexcept
Get the first occurrence of a stream of the given type.
virtual void log_macro(const category &category, verbosity eVerbosity, std::thread::id threadId, std::chrono::system_clock::time_point messageTime, string_view svFile, string_view svFunction, int nLine, logger_string_pool::item message)
Main log function: log to all streams. For macro and internal usage.
virtual void reset() noexcept
Reset logger and clear all streams.
virtual void flush()
Flush all streams.
compile_pattern_result set_default_pattern(string sPattern) noexcept
Compile and set the default pattern for log messages.
Fixed-size atomic string pool.
Small Buffer Object for polymorphic classes.
Inherit the necessary singleton class from this.
#define QX_FLAGS_ENUM_CLASS(enumName)
Define to let to use this enum class in different binary operations returning qx::flags.
logger & get_logger() noexcept
Get the logger instance used in QX_LOG macros.