qxLib
asserts_manager.inl
Go to the documentation of this file.
1 /**
2 
3  @file asserts_manager.inl
4  @author Khrapov
5  @date 27.12.2025
6  @copyright © Nick Khrapov, 2025. All right reserved.
7 
8 **/
9 
10 namespace qx
11 {
12 
14  string_view svCondition,
15  const category& category,
16  assert_type eAssertType,
17  string sUserMessage,
18  string_view svFunction,
19  string_view svFile,
20  i32 nLine)
21 {
22  if (m_Config.bLogAssertion)
23  {
24  QX_LOG_REF(category, m_Config.getVerbosity(eAssertType), "[{}] {}", svCondition, sUserMessage);
25 
26  // the error must present when debug break is called
27  get_logger().flush();
28 
29  std::shared_lock _(get_logger().get_streams_mutex());
30  if (auto* pStream = get_logger().get_stream<error_context_stream>())
31  pStream->on_error(std::this_thread::get_id());
32  }
33 
34  if (m_Config.onAssertion)
35  m_Config.onAssertion(svCondition, category, eAssertType, sUserMessage, svFunction, svFile, nLine);
36 
37 #if QX_WIN
38  return ::IsDebuggerPresent();
39 #else
40  return false;
41 #endif
42 }
43 
44 inline void asserts_manager::exit(const category& category, assert_type eAssertType)
45 {
46  if (m_Config.onExit)
47  m_Config.onExit(category, eAssertType);
48 }
49 
51 {
52  return m_Config;
53 }
54 
56 {
57  m_Config = std::move(config);
58 }
59 
60 } // namespace qx
void set_config(config config)
Set config.
void exit(const category &category, assert_type eAssertType)
Called in fatal assertions to exit the application.
bool do_assert(string_view svCondition, const category &category, assert_type eAssertType, string sUserMessage, string_view svFunction, string_view svFile, i32 nLine)
An entry point for all assertions.
const config & get_config() const
Get config.
A category is a class that identifies a particular piece of code. This code can be located in differe...
Definition: category.h:59
virtual void flush()
Flush all streams.
Definition: logger.inl:163
logger & get_logger() noexcept
Get the logger instance used in QX_LOG macros.
Definition: logger.h:267
#define QX_LOG_REF(category, eVerbosity,...)
Log with category and with non compile time category check.
Definition: logger.h:48
std::int32_t i32
− 9 223 372 036 854 775 808 .. 9 223 372 036 854 775 807
Definition: typedefs.h:32