6#include <source_location>
11template<
class... A>
void printout (
const char *format,
const A &...args) ASE_PRINTF (1, 0);
12template<
class... A>
void printerr (
const char *format,
const A &...args) ASE_PRINTF (1, 0);
21 const char *
const cstr =
nullptr;
28template<
class ...A>
void fatal_error (
const LogFormat &format,
const A &...args) ASE_NORETURN;
29template<
class ...A>
void warning (
const char *format,
const A &...args);
30template<
class ...A>
void info (
const char *format,
const A &...args) ASE_ALWAYS_INLINE;
31template<
class ...A>
void diag (
const char *format,
const A &...args) ASE_ALWAYS_INLINE;
34void logging_handle_terminate ();
35template<
class ...A>
void debug (
const char *cond,
const char *format,
const A &...args) ASE_ALWAYS_INLINE;
38const
char* getenv_ase_debug ();
42enum Logging :
int { FATAL, ASSERTION, WARN, HINT, INFO, DIAG, TRACE, DEBUGALL, };
44void logging_abort (Logging level,
const std::string &message,
const char *file, uint32_t line,
const char *func)
noexcept;
45void logging (Logging level,
const std::string &message,
const char *file, uint32_t line,
const char *func)
noexcept;
50bool logging_configure (
bool to_file, Logging level = Logging (-1));
53inline bool ASE_ALWAYS_INLINE ASE_PURE
60template<
class ...Args>
inline void ASE_ALWAYS_INLINE
61debug (
const char *cond,
const char *format,
const Args &...args)
73template<
class ...Args>
inline void ASE_ALWAYS_INLINE
74info (
const char *format,
const Args &...args)
76 logging (INFO,
string_format (format, args...),
nullptr, -1,
nullptr);
80template<
class ...Args>
inline void ASE_ALWAYS_INLINE
81diag (
const char *format,
const Args &...args)
89template<
class ...Args>
void
90fatal_error (
const LogFormat &format,
const Args &...args)
93 format.location.file_name(), format.location.line(), format.location.function_name());
97template<
class ...Args>
void
98warning (
const char *format,
const Args &...args)
100 logging (WARN,
string_format (format, args...),
nullptr, -1,
nullptr);
104template<
class... Args>
void
105printout (
const char *format,
const Args &...args)
111template<
class... Args>
void
112printerr (
const char *format,
const Args &...args)
#define ASE_UNLIKELY(expr)
Compiler hint to optimize for expr evaluating to false.
The Anklang C++ API namespace.
std::string string_format(const char *format, const Args &...args) __attribute__((__format__(__printf__
Format a string similar to sprintf(3) with support for std::string and std::ostringstream convertible...
void stdio_flush(uint8 code, const String &txt) noexcept
Handle stdout and stderr printing with flushing.
uint8_t uint8
An 8-bit unsigned integer.
void logging_debug(const char *cond, const std::string &message) noexcept
Print a debug/diag message, called from Ase::debug().
uint64_t timestamp_now()
Current time in µseconds.
bool ase_debugging_enabled
Flag to optimize checks for debugging.
bool debug_enabled() ASE_PURE
Check if any kind of debugging is enabled by $ASE_DEBUG.
bool logging_fatal_warnings
Global flag to cause the program to abort on warnings.
std::string String
Convenience alias for std::string.
bool debug_key_enabled(const char *conditional) noexcept
Check if conditional is enabled by $ASE_DEBUG.