Toast Engine
Loading...
Searching...
No Matches
log.hpp File Reference

Public logging interface for the engine. More...

#include "export.hpp"
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <format>
#include <string_view>
#include <tracy/Tracy.hpp>
Include dependency graph for log.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TOAST_FILE_NAME   ::logging::_detail::getOnlyName(__FILE__)
#define TOAST_LOG_IMPL(severity, sink, ...)
#define TOAST_TRACE(sink, ...)
 Writes a message to the log console.
#define TOAST_INFO(sink, ...)
 logs an information message
#define TOAST_WARN(sink, ...)
 Indicates possible code missuse.
#define TOAST_ERROR(sink, ...)
 An error is a problem that should be addressed as soon as possible.
#define TOAST_CRITICAL(sink, ...)
 Something has failed and we cannot recover from this.
#define TOAST_ASSERT(condition, sink, ...)
#define TOAST_NOT_IMPLEMENTED   TOAST_ASSERT(false, "Engine", "Not implemented")

Functions

constexpr auto logging::_detail::getOnlyName (std::string_view path) -> std::string_view
void TOAST_API logging::_detail::log (uint8_t severity, std::string_view file_name, unsigned line_number, std::string_view sink, std::string_view message)

Detailed Description

Public logging interface for the engine.

Author
Xein
Date
17 Mar 2026

Macro Definition Documentation

◆ TOAST_CRITICAL

#define TOAST_CRITICAL ( sink,
... )
Value:
do { \
TOAST_LOG_IMPL(4, sink, __VA_ARGS__); \
std::abort(); \
} while (0)

Something has failed and we cannot recover from this.

Parameters
sinkclass logging the message
...fmt formatted message

We will terminate the process when a critical error happens via std::abort();

◆ TOAST_ERROR

#define TOAST_ERROR ( sink,
... )
Value:
TOAST_LOG_IMPL(3, sink, __VA_ARGS__)

An error is a problem that should be addressed as soon as possible.

Parameters
sinkclass logging the message
...fmt formatted message

The engine will be considered as an undefined behaviour from the moment an error happens since an "unrecoverable-in-runtime" problem has ocurred

◆ TOAST_INFO

#define TOAST_INFO ( sink,
... )
Value:
TOAST_LOG_IMPL(1, sink, __VA_ARGS__)

logs an information message

Parameters
sinkclass logging the message
...fmt formatted message

Indicates that a meaningful action has happened

Information messages should mark a before and after when reading a log; if you are not sure if your message is important enough, then it's probably not an info log

◆ TOAST_LOG_IMPL

#define TOAST_LOG_IMPL ( severity,
sink,
... )
Value:
do { \
::logging::_detail::log(severity, TOAST_FILE_NAME, __LINE__, sink, std::format(__VA_ARGS__)); \
} while (0)

◆ TOAST_TRACE

#define TOAST_TRACE ( sink,
... )
Value:
TOAST_LOG_IMPL(0, sink, __VA_ARGS__)

Writes a message to the log console.

Parameters
sinkclass logging the message
...fmt formatted message

A trace means "any text that should be logged". There can be multiple importances of traces but anything that is not a really important message falls into this category

If you are logging something and you don't know if reading this log will be meaningful in half an hour, or even a week, then it is a trace

If you will stop caring about this log as soon as you finish working on your task, then it is a trace

◆ TOAST_WARN

#define TOAST_WARN ( sink,
... )
Value:
TOAST_LOG_IMPL(2, sink, __VA_ARGS__)

Indicates possible code missuse.

Parameters
sinkclass logging the message
...fmt formatted message

Something didn't happen as expected but should not be a major problem. It can potentially lead to bugs and errors so a warning shouldn't be ignored