Foundation
Loading...
Searching...
No Matches
Namespaces | Macros | Functions | Variables
Logging.hpp File Reference
#include <memory>
#include <exception>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/dist_sink.h>
#include <spdlog/sinks/ringbuffer_sink.h>

Go to the source code of this file.

Namespaces

namespace  Foundation
 
namespace  Foundation::Core
 Allocators, Data Structures and introspection implementations.
 

Macros

#define LOG_GET_GLOBAL_SINK()    Foundation::Core::getLoggingSink()
 
#define LOG_GET_LOGGER(TAG)    Foundation::Core::getLogger(#TAG)
 
#define LOG_RUNTIME(TAG, LEVEL, ...)    SPDLOG_LOGGER_CALL(LOG_GET_LOGGER(TAG), spdlog::level::LEVEL __VA_OPT__(,) __VA_ARGS__)
 
#define CHECK(expr)
 
#define CHECK_MSG(expr, format_str, ...)
 

Functions

std::shared_ptr< spdlog::sinks::dist_sink_mt > Foundation::Core::getLoggingSink ()
 
std::shared_ptr< spdlog::sinks::ringbuffer_sink_mt > Foundation::Core::getBacktraceSink ()
 
spdlog::logger * Foundation::Core::getLogger (const char *name)
 

Variables

const size_t Foundation::Core::kMaxBacktraceLogMessages = 1000
 

Macro Definition Documentation

◆ CHECK

#define CHECK (   expr)
Value:
if(!(expr)) { \
LOG_RUNTIME(Core, err, "Check failed: {}", #expr); \
throw std::runtime_error( #expr ); \
}

◆ CHECK_MSG

#define CHECK_MSG (   expr,
  format_str,
  ... 
)
Value:
if(!(expr)) { \
std::string __message = fmt::format(format_str __VA_OPT__(,) __VA_ARGS__); \
LOG_RUNTIME(Core, err, __message); \
throw std::runtime_error(__message); \
}

◆ LOG_GET_GLOBAL_SINK

#define LOG_GET_GLOBAL_SINK ( )     Foundation::Core::getLoggingSink()

◆ LOG_GET_LOGGER

#define LOG_GET_LOGGER (   TAG)     Foundation::Core::getLogger(#TAG)

◆ LOG_RUNTIME

#define LOG_RUNTIME (   TAG,
  LEVEL,
  ... 
)     SPDLOG_LOGGER_CALL(LOG_GET_LOGGER(TAG), spdlog::level::LEVEL __VA_OPT__(,) __VA_ARGS__)