Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
26 #ifndef JAU_DEBUG_HPP_
27 #define JAU_DEBUG_HPP_
78 #define DBG_PRINT(...) { if( jau::environment::get().debug ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }
81 #define DBG_JNI_PRINT(...) { if( jau::environment::get().debug_jni ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }
91 #define WORDY_PRINT(...) { if( jau::environment::get().verbose ) { jau::WORDY_PRINT_impl(__VA_ARGS__); } }
94 #define PERF_TS_T0_BASE() const uint64_t _t0 = jau::getCurrentMilliseconds()
96 #define PERF_TS_TD_BASE(m) { const uint64_t _td = jau::getCurrentMilliseconds() - _t0; \
97 fprintf(stderr, "[%'9" PRIu64 "] PERF %s done in %d ms,\n", jau::environment::getElapsedMillisecond(), (m), (int)_td); }
99 #define PERF_TS_T0() PERF_TS_T0_BASE()
100 #define PERF_TS_TD(m) PERF_TS_TD_BASE(m)
103 #define PERF_TS_TD(m)
105 #ifdef PERF2_PRINT_ON
106 #define PERF2_TS_T0() PERF_TS_T0_BASE()
107 #define PERF2_TS_TD(m) PERF_TS_TD_BASE(m)
109 #define PERF2_TS_T0()
110 #define PERF2_TS_TD(m)
112 #ifdef PERF3_PRINT_ON
113 #define PERF3_TS_T0() PERF_TS_T0_BASE()
114 #define PERF3_TS_TD(m) PERF_TS_TD_BASE(m)
116 #define PERF3_TS_T0()
117 #define PERF3_TS_TD(m)
121 void ABORT_impl(
const char *func,
const char *file,
const int line,
const char * format, ...) noexcept;
124 #define ABORT(...) { jau::ABORT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }
127 void ERR_PRINTv(
const char *func,
const char *file,
const int line,
const char * format, va_list args) noexcept;
129 void ERR_PRINT_impl(
const char *prefix,
const bool backtrace,
const char *func,
const char *file,
const int line,
const char * format, ...) noexcept;
132 #define ERR_PRINT(...) { jau::ERR_PRINT_impl("Error", true , __func__, __FILE__, __LINE__, __VA_ARGS__); }
135 #define ERR_PRINT2(...) { jau::ERR_PRINT_impl("Error", false , __func__, __FILE__, __LINE__, __VA_ARGS__); }
138 #define IRQ_PRINT(...) { jau::ERR_PRINT_impl("Interrupted", false , __func__, __FILE__, __LINE__, __VA_ARGS__); }
141 void WARN_PRINTv(
const char *func,
const char *file,
const int line,
const char * format, va_list args) noexcept;
143 void WARN_PRINT_impl(
const char *func,
const char *file,
const int line,
const char * format, ...) noexcept;
146 #define WARN_PRINT(...) { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }
149 void INFO_PRINT(
const char * format, ...) noexcept;
152 void PLAIN_PRINT(const
bool printPrefix, const
char * format, ...) noexcept;
160 int fprintf_td(FILE* stream, const
char * format, ...) noexcept;
165 #define COND_PRINT(C, ...) { if( C ) { jau::COND_PRINT_impl(__VA_ARGS__); } }
170 fprintf(stderr,
"%s: Start: %zu elements\n", prefix.c_str(), (
size_t)list.size());
172 for (
auto it = list.begin(); it != list.end(); idx++) {
173 typename List::value_type & e = *it;
174 if (
nullptr != e ) {
175 fprintf(stderr,
"%s[%d]: useCount %zu, mem %p\n", prefix.c_str(), idx, (
size_t)e.use_count(), e.get());
177 fprintf(stderr,
"%s[%d]: NULL\n", prefix.c_str(), idx);
void print_backtrace(const bool skip_anon_frames, const jau::snsize_t max_frames=-1, const jau::nsize_t skip_frames=2) noexcept
Prints the de-mangled backtrace string separated by newline excluding this function to stderr,...
void WORDY_PRINT_impl(const char *format,...) noexcept
std::string get_backtrace(const bool skip_anon_frames, const jau::snsize_t max_frames=-1, const jau::nsize_t skip_frames=1) noexcept
Returns a de-mangled backtrace string separated by newline excluding this function.
void ERR_PRINTv(const char *func, const char *file, const int line, const char *format, va_list args) noexcept
Use for unconditional error messages, prefix '[elapsed_time] Error @ file:line: '.
int fprintf_td(FILE *stream, const char *format,...) noexcept
Convenient fprintf() invocation, prepending the environment::getElapsedMillisecond() timestamp.
void INFO_PRINT(const char *format,...) noexcept
Use for unconditional informal messages, prefix '[elapsed_time] Info: '.
void WARN_PRINT_impl(const char *func, const char *file, const int line, const char *format,...) noexcept
void PLAIN_PRINT(const bool printPrefix, const char *format,...) noexcept
Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true.
int_fast32_t snsize_t
Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
void ERR_PRINT_impl(const char *prefix, const bool backtrace, const char *func, const char *file, const int line, const char *format,...) noexcept
void WARN_PRINTv(const char *func, const char *file, const int line, const char *format, va_list args) noexcept
Use for unconditional warning messages, prefix '[elapsed_time] Warning @ file:line: '.
void printSharedPtrList(std::string prefix, List &list) noexcept
void ABORT_impl(const char *func, const char *file, const int line, const char *format,...) noexcept
Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ file:line: '...
void COND_PRINT_impl(const char *format,...) noexcept
void DBG_PRINT_impl(const char *format,...) noexcept