Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Namespaces | Macros | Functions
debug.hpp File Reference
#include <memory>
#include <cstdint>
#include <cinttypes>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdarg>
#include <errno.h>
#include <jau/environment.hpp>
#include <jau/backtrace.hpp>
Include dependency graph for debug.hpp:

Go to the source code of this file.

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 

Macros

#define ABORT(...)   { jau::ABORT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ file:line func: '. More...
 
#define COND_PRINT(C, ...)   { if( C ) { jau::COND_PRINT_impl(__VA_ARGS__); } }
 Use for conditional plain messages, prefix '[elapsed_time] '. More...
 
#define DBG_JNI_PRINT(...)   { if( jau::environment::get().debug_jni ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }
 Use for environment-variable environment::DEBUG_JNI conditional debug messages, prefix '[elapsed_time] Debug: '. More...
 
#define DBG_PRINT(...)   { if( jau::environment::get().debug ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }
 Use for environment-variable environment::DEBUG conditional debug messages, prefix '[elapsed_time] Debug: '. More...
 
#define DBG_WARN_PRINT(...)   { if( jau::environment::get().debug ) { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); } }
 Use for environment-variable environment::DEBUG conditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE FUNC: '. More...
 
#define ERR_PRINT(...)   { jau::ERR_PRINT_impl("Error", true /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '. More...
 
#define ERR_PRINT2(...)   { jau::ERR_PRINT_impl("Error", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '. More...
 
#define IRQ_PRINT(...)   { jau::ERR_PRINT_impl("Interrupted", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional interruption messages, prefix '[elapsed_time] Interrupted @ FILE:LINE FUNC: '. More...
 
#define PERF2_TS_T0()
 
#define PERF2_TS_TD(m)
 
#define PERF3_TS_T0()
 
#define PERF3_TS_TD(m)
 
#define PERF_TS_T0()
 
#define PERF_TS_T0_BASE()   const uint64_t _t0 = jau::getCurrentMilliseconds()
 
#define PERF_TS_TD(m)
 
#define PERF_TS_TD_BASE(m)
 
#define WARN_PRINT(...)   { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE FUNC: '. More...
 
#define WORDY_PRINT(...)   { if( jau::environment::get().verbose ) { jau::WORDY_PRINT_impl(__VA_ARGS__); } }
 Use for environment-variable environment::VERBOSE conditional verbose messages, prefix '[elapsed_time] Wordy: '. More...
 

Functions

void jau::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 func: '. More...
 
void jau::COND_PRINT_impl (const char *format,...) noexcept
 
void jau::DBG_PRINT_impl (const char *format,...) noexcept
 
void jau::ERR_PRINT_impl (const char *prefix, const bool backtrace, const char *func, const char *file, const int line, const char *format,...) noexcept
 
void jau::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 func: '. More...
 
int jau::fprintf_td (const uint64_t elapsed_ms, FILE *stream, const char *format,...) noexcept
 Convenient fprintf() invocation, prepending the given elapsed_ms timestamp. More...
 
int jau::fprintf_td (FILE *stream, const char *format,...) noexcept
 Convenient fprintf() invocation, prepending the environment::getElapsedMillisecond() timestamp. More...
 
void jau::INFO_PRINT (const char *format,...) noexcept
 Use for unconditional informal messages, prefix '[elapsed_time] Info: '. More...
 
void jau::PLAIN_PRINT (const bool printPrefix, const char *format,...) noexcept
 Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true. More...
 
template<class List >
void jau::printSharedPtrList (const std::string &prefix, List &list) noexcept
 
void jau::WARN_PRINT_impl (const char *func, const char *file, const int line, const char *format,...) noexcept
 
void jau::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 func: '. More...
 
void jau::WORDY_PRINT_impl (const char *format,...) noexcept
 

Macro Definition Documentation

◆ DBG_PRINT

#define DBG_PRINT (   ...)    { if( jau::environment::get().debug ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }

Use for environment-variable environment::DEBUG conditional debug messages, prefix '[elapsed_time] Debug: '.

Definition at line 52 of file debug.hpp.

◆ DBG_WARN_PRINT

#define DBG_WARN_PRINT (   ...)    { if( jau::environment::get().debug ) { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); } }

Use for environment-variable environment::DEBUG conditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE FUNC: '.

Definition at line 55 of file debug.hpp.

◆ DBG_JNI_PRINT

#define DBG_JNI_PRINT (   ...)    { if( jau::environment::get().debug_jni ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }

Use for environment-variable environment::DEBUG_JNI conditional debug messages, prefix '[elapsed_time] Debug: '.

Definition at line 58 of file debug.hpp.

◆ WORDY_PRINT

#define WORDY_PRINT (   ...)    { if( jau::environment::get().verbose ) { jau::WORDY_PRINT_impl(__VA_ARGS__); } }

Use for environment-variable environment::VERBOSE conditional verbose messages, prefix '[elapsed_time] Wordy: '.

'Wordy' is the shorter English form of the Latin word 'verbosus', from which the word 'verbosity' is sourced.

Definition at line 68 of file debug.hpp.

◆ PERF_TS_T0_BASE

#define PERF_TS_T0_BASE ( )    const uint64_t _t0 = jau::getCurrentMilliseconds()

Definition at line 71 of file debug.hpp.

◆ PERF_TS_TD_BASE

#define PERF_TS_TD_BASE (   m)
Value:
{ const uint64_t _td = jau::getCurrentMilliseconds() - _t0; \
fprintf(stderr, "[%s] PERF %s done in %d ms,\n", jau::to_decstring(jau::environment::getElapsedMillisecond(), ',', 9).c_str(), (m), (int)_td); }
static uint64_t getElapsedMillisecond() noexcept
Returns current elapsed monotonic time in milliseconds since module startup, see startupTimeMilliseco...
std::string to_decstring(const value_type &v, const char separator=',', const nsize_t width=0) noexcept
Produce a decimal string representation of an integral integer value.
uint64_t getCurrentMilliseconds() noexcept
Returns current monotonic time in milliseconds.
Definition: basic_types.cpp:64

Definition at line 73 of file debug.hpp.

◆ PERF_TS_T0

#define PERF_TS_T0 ( )

Definition at line 79 of file debug.hpp.

◆ PERF_TS_TD

#define PERF_TS_TD (   m)

Definition at line 80 of file debug.hpp.

◆ PERF2_TS_T0

#define PERF2_TS_T0 ( )

Definition at line 86 of file debug.hpp.

◆ PERF2_TS_TD

#define PERF2_TS_TD (   m)

Definition at line 87 of file debug.hpp.

◆ PERF3_TS_T0

#define PERF3_TS_T0 ( )

Definition at line 93 of file debug.hpp.

◆ PERF3_TS_TD

#define PERF3_TS_TD (   m)

Definition at line 94 of file debug.hpp.

◆ ABORT

#define ABORT (   ...)    { jau::ABORT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ file:line func: '.

Function also appends last errno and strerror(errno).

Definition at line 101 of file debug.hpp.

◆ ERR_PRINT

#define ERR_PRINT (   ...)    { jau::ERR_PRINT_impl("Error", true /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '.

Function also appends last errno, strerror(errno) and full backtrace

Definition at line 109 of file debug.hpp.

◆ ERR_PRINT2

#define ERR_PRINT2 (   ...)    { jau::ERR_PRINT_impl("Error", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '.

Function also appends last errno and strerror(errno). No backtrace.

Definition at line 112 of file debug.hpp.

◆ IRQ_PRINT

#define IRQ_PRINT (   ...)    { jau::ERR_PRINT_impl("Interrupted", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional interruption messages, prefix '[elapsed_time] Interrupted @ FILE:LINE FUNC: '.

Function also appends last errno and strerror(errno).

Definition at line 115 of file debug.hpp.

◆ WARN_PRINT

#define WARN_PRINT (   ...)    { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE FUNC: '.

Definition at line 123 of file debug.hpp.

◆ COND_PRINT

#define COND_PRINT (   C,
  ... 
)    { if( C ) { jau::COND_PRINT_impl(__VA_ARGS__); } }

Use for conditional plain messages, prefix '[elapsed_time] '.

Definition at line 151 of file debug.hpp.