IRSOL
C++ code implementing socket server for interacting with Baumer camera.
assert.cpp
Go to the documentation of this file.
1#include "irsol/assert.hpp"
2
3#include "irsol/logging.hpp"
4
5#include <ppk_assert/ppk_assert.hpp>
6
7namespace irsol {
8void
9setAssertHandler(ppk::assert::implementation::AssertHandler handler)
10{
11 ppk::assert::implementation::setAssertHandler(handler);
12}
13void
15{
16 IRSOL_LOG_INFO("Initializing irsol assert handler");
18}
19
20namespace internal {
21ppk::assert::implementation::AssertAction::AssertAction
23 const char* file,
24 int line,
25 const char* function,
26 const char* expression,
27 int level,
28 const char* message)
29{
30 switch(level) {
31 case ppk::assert::implementation::AssertLevel::Debug: {
33 "Assertion failed at {0}:{1} -> '{2}' is false: {3}.", file, line, expression, message);
34 return ppk::assert::implementation::AssertAction::Ignore;
35 }
36
37 case ppk::assert::implementation::AssertLevel::Error: {
39 "Assertion failed at {0}:{1} -> '{2}' is false: {3}.", file, line, expression, message);
40 return ppk::assert::implementation::AssertAction::Throw;
41 }
42 case ppk::assert::implementation::AssertLevel::Fatal: {
44 "Assertion failed at {0}:{1} ({2}) -> '{3}' is false: {4}.",
45 file,
46 line,
47 function,
48 expression,
49 message);
50 return ppk::assert::implementation::AssertAction::Abort;
51 }
52 default: {
53#ifdef DEBUG
55 "Unknown assertion level: {0}, at {1}:{2} -> '{3}' is false: {4}. Aborting program.",
56 level,
57 file,
58 line,
59 expression,
60 message);
61 return ppk::assert::implementation::AssertAction::Throw;
62#else
64 "Unknown assertion level: {0}, at {1}:{2} -> '{3}' is false: {4}. Aborting program.",
65 level,
66 file,
67 line,
68 expression,
69 message);
70 return ppk::assert::implementation::AssertAction::Abort;
71#endif
72 }
73 }
74}
75} // namespace internal
76
77} // namespace irsol
Assertion macros and utilities based on the PPK_ASSERT library.
void setAssertHandler(AssertHandler handler)
Sets a custom assertion handler function.
ppk::assert::implementation::AssertAction::AssertAction assertHandler(const char *file, int line, const char *function, const char *expression, int level, const char *message)
Internal default assertion handler implementation.
Definition assert.cpp:22
void initAssertHandler()
Initializes the assertion handler system.
Definition assert.cpp:14
#define IRSOL_LOG_FATAL(...)
Logs a fatal (critical) message using the default logger.
Definition logging.hpp:95
#define IRSOL_LOG_INFO(...)
Logs an info-level message using the default logger.
Definition logging.hpp:92
#define IRSOL_LOG_ERROR(...)
Logs an error-level message using the default logger.
Definition logging.hpp:94
#define IRSOL_LOG_WARN(...)
Logs a warning-level message using the default logger.
Definition logging.hpp:93
Logging utilities and configuration for the irsol library.