12 #ifndef DOCWIRE_LOG_SCOPE_H
13 #define DOCWIRE_LOG_SCOPE_H
15 #include "log_entry.h"
24 template <
typename... Args>
27 scope(
const Args&... args,
const source_location& location = source_location::current()) noexcept
28 : m_location(location), m_args_tuple(args...)
30 if (detail::is_logging_enabled())
32 docwire::log::entry(m_location, std::tuple_cat(std::make_tuple(
log::scope_enter{}), m_args_tuple));
38 if (detail::is_logging_enabled())
41 docwire::log::entry(m_location, std::tuple_cat(std::make_tuple(
log::scope_exit{}), m_args_tuple));
48 std::tuple<Args...> m_args_tuple;
60 template <
typename... T>
61 [[maybe_unused]]
explicit empty_scope(T&&...) noexcept
67 constexpr
bool is_debug_build =
false;
70 constexpr
bool is_debug_build =
true;
83 template <
typename... Args>
84 class scope :
public std::conditional_t<
85 detail::is_debug_build || detail::should_log_in_release<Args...>(),
86 detail::scope<Args...>,
94 [[maybe_unused]]
explicit scope(
const Args&... args,
const source_location& location = source_location::current()) noexcept
95 : base(args..., location)
100 template<
typename... Args>
105 #define DOCWIRE_LOG_SCOPE_CONCAT_IMPL(a, b) a##b
106 #define DOCWIRE_LOG_SCOPE_CONCAT(a, b) DOCWIRE_LOG_SCOPE_CONCAT_IMPL(a, b)
108 #define DOCWIRE_LOG_SCOPE(...) \
109 [[maybe_unused]] docwire::log::scope \
110 DOCWIRE_LOG_SCOPE_CONCAT(docwire_log_scope_object_at_line_, __LINE__) {DOCWIRE_DIAGNOSTIC_CONTEXT_MAKE_TUPLE(__VA_ARGS__)}
112 #ifdef DOCWIRE_ENABLE_SHORT_MACRO_NAMES
113 #define log_scope(...) DOCWIRE_LOG_SCOPE(__VA_ARGS__)
RAII class for logging scope entry and exit.
Represents a logging scope.
Provides a modern, high-performance, and structured logging framework.
A fallback implementation of source_location for compilers that do not support std::source_location.
A no-op scope class used when logging is disabled or in release builds.
Tag automatically added to a log entry when a log_scope is entered.
Tag automatically added to a log entry when a log_scope is exited.