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_view svUserMessage,
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, svUserMessage);
25 
26  // the error must present when debug break is called
27  get_logger().flush();
28  }
29 
30  if (m_Config.onAssertion)
31  m_Config.onAssertion(svCondition, category, eAssertType, svUserMessage, svFunction, svFile, nLine);
32 
33 #if QX_WIN
34  return ::IsDebuggerPresent();
35 #else
36  return false;
37 #endif
38 }
39 
40 inline void asserts_manager::exit(const category& category, assert_type eAssertType)
41 {
42  if (m_Config.onExit)
43  m_Config.onExit(category, eAssertType);
44 }
45 
47 {
48  return m_Config;
49 }
50 
52 {
53  m_Config = std::move(config);
54 }
55 
56 } // namespace qx
bool do_assert(string_view svCondition, const category &category, assert_type eAssertType, string_view svUserMessage, string_view svFunction, string_view svFile, i32 nLine)
An entry point for all assertions.
void set_config(config config)
Set config.
void exit(const category &category, assert_type eAssertType)
Called in fatal assertions to exit the application.
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:41
logger & get_logger()
Get the logger instance used in QX_LOG macros.
Definition: logger.h:179
#define QX_LOG_REF(category, eVerbosity,...)
Log with category and with non compile time category check.
Definition: logger.h:55
std::int32_t i32
− 9 223 372 036 854 775 808 .. 9 223 372 036 854 775 807
Definition: typedefs.h:32