Foundation
Loading...
Searching...
No Matches
Namespaces | Macros | Enumerations | Functions
Logging.hpp File Reference
#include <fmt/base.h>
#include <fmt/format.h>
#include <cstdlib>
#include <iterator>
#include "Allocator.hpp"

Go to the source code of this file.

Namespaces

namespace  Foundation
 
namespace  Foundation::Core
 Lock-free atomic primitives and implementations of data structures.
 

Macros

#define FMT_EXCEPTIONS   0
 
#define LOG(TAG, LEVEL, FORMAT, ...)   Foundation_Log(#TAG, LEVEL, FORMAT __VA_OPT__(,) __VA_ARGS__);
 
#define FOUNDATION_TRAP()   __builtin_trap()
 
#define FOUNDATION_STRINGIFY_2(x)   #x
 
#define FOUNDATION_STRINGIFY(x)   FOUNDATION_STRINGIFY_2(x)
 
#define FOUNDATION_SOURCE_LOC   __FILE__ "@" FOUNDATION_STRINGIFY(__LINE__)
 
#define CHECK(expr)
 
#define CHECK_MSG(expr, format_str, ...)
 

Enumerations

enum  LogLevel { LogDebug , LogInfo , LogWarn , LogError }
 

Functions

template<bool Ansi = true>
constexpr const char * format_as (LogLevel level)
 
void Foundation_LogImpl (LogLevel level, const char *tag, const char *formatted)
 
void Foundation_PrintImpl (const char *formatted, bool flush)
 
template<typename ... Args>
void Foundation_Log (const char *tag, LogLevel level, fmt::format_string< Args... > format, Args &&... args)
 
template<typename... Args>
void Foundation::Core::Print (fmt::format_string< Args... > format, Args &&... args)
 
template<typename... Args>
void Foundation::Core::Println (fmt::format_string< Args... > format, Args &&... args)
 

Macro Definition Documentation

◆ CHECK

#define CHECK (   expr)
Value:
do { \
if (!(expr)) [[unlikely]] { \
LOG(Core, LogError, "Check failed: {}", FOUNDATION_SOURCE_LOC ":" #expr); \
FOUNDATION_TRAP(); \
std::terminate(); \
} \
} while (false);
#define FOUNDATION_SOURCE_LOC
Definition Logging.hpp:91
@ LogError
Definition Logging.hpp:17

◆ CHECK_MSG

#define CHECK_MSG (   expr,
  format_str,
  ... 
)
Value:
do { \
if (!(expr)) [[unlikely]] { \
LOG(Core, LogError, "Check failed: {}", FOUNDATION_SOURCE_LOC ":" #expr); \
LOG(Core, LogError, format_str __VA_OPT__(,) __VA_ARGS__); \
FOUNDATION_TRAP(); \
std::terminate(); \
} \
} while (false);

◆ FMT_EXCEPTIONS

#define FMT_EXCEPTIONS   0

◆ FOUNDATION_SOURCE_LOC

#define FOUNDATION_SOURCE_LOC   __FILE__ "@" FOUNDATION_STRINGIFY(__LINE__)

◆ FOUNDATION_STRINGIFY

#define FOUNDATION_STRINGIFY (   x)    FOUNDATION_STRINGIFY_2(x)

◆ FOUNDATION_STRINGIFY_2

#define FOUNDATION_STRINGIFY_2 (   x)    #x

◆ FOUNDATION_TRAP

#define FOUNDATION_TRAP ( )    __builtin_trap()

◆ LOG

#define LOG (   TAG,
  LEVEL,
  FORMAT,
  ... 
)    Foundation_Log(#TAG, LEVEL, FORMAT __VA_OPT__(,) __VA_ARGS__);

Enumeration Type Documentation

◆ LogLevel

enum LogLevel
Enumerator
LogDebug 
LogInfo 
LogWarn 
LogError 

Function Documentation

◆ format_as()

template<bool Ansi = true>
constexpr const char * format_as ( LogLevel  level)
constexpr

◆ Foundation_Log()

template<typename ... Args>
void Foundation_Log ( const char *  tag,
LogLevel  level,
fmt::format_string< Args... >  format,
Args &&...  args 
)

◆ Foundation_LogImpl()

void Foundation_LogImpl ( LogLevel  level,
const char *  tag,
const char *  formatted 
)
extern

◆ Foundation_PrintImpl()

void Foundation_PrintImpl ( const char *  formatted,
bool  flush 
)
extern