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 (
const std::string &log_file_ident, Logging level = Logging (-1));
56inline bool ASE_ALWAYS_INLINE ASE_PURE
63template<
class ...Args>
inline void ASE_ALWAYS_INLINE
64debug (
const char *cond,
const char *format,
const Args &...args)
76template<
class ...Args>
inline void ASE_ALWAYS_INLINE
77info (
const char *format,
const Args &...args)
79 logging (INFO,
string_format (format, args...),
nullptr, -1,
nullptr);
83template<
class ...Args>
inline void ASE_ALWAYS_INLINE
84diag (
const char *format,
const Args &...args)
92template<
class ...Args>
void
93fatal_error (
const LogFormat &format,
const Args &...args)
96 format.location.file_name(), format.location.line(), format.location.function_name());
100template<
class ...Args>
void
101warning (
const char *format,
const Args &...args)
103 logging (WARN,
string_format (format, args...),
nullptr, -1,
nullptr);
107template<
class... Args>
void
108printout (
const char *format,
const Args &...args)
114template<
class... Args>
void
115printerr (
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_prune_old_logs(double age_seconds)
Delete log files older than age seconds.
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.