TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_logging.h File Reference
#include <stdint.h>
#include <span>
#include <string_view>
#include <type_traits>
#include <gui_core/gui_hash.h>

Go to the source code of this file.

Classes

struct  tachyon::Diagnostics::LogCategory
 A subsystem's log category. More...
struct  tachyon::Diagnostics::LogArg
 One argument. More...
struct  tachyon::Diagnostics::LogRecord
 One message as sinks and CopyRecentLogRecords see it. More...

Namespaces

namespace  tachyon
namespace  tachyon::Diagnostics

Macros

#define TACHYON_LOG_TRACE(category, ...)
#define TACHYON_LOG_DEBUG(category, ...)
#define TACHYON_LOG_INFO(category, ...)
#define TACHYON_LOG_WARNING(category, ...)
#define TACHYON_LOG_ERROR(category, ...)
#define TACHYON_LOG_CRITICAL(category, ...)

Typedefs

using tachyon::Diagnostics::LogSinkFn = void (*)(const LogRecord& record, void* context)
 A log sink. Sinks run on the emitting thread, under the logger's lock.

Enumerations

enum class  tachyon::Diagnostics::LogSeverity : uint8_t {
  tachyon::Diagnostics::LogSeverity::Trace = 0 , tachyon::Diagnostics::LogSeverity::Debug , tachyon::Diagnostics::LogSeverity::Info , tachyon::Diagnostics::LogSeverity::Warning ,
  tachyon::Diagnostics::LogSeverity::Error , tachyon::Diagnostics::LogSeverity::Critical
}

Functions

const char * tachyon::Diagnostics::LogSeverityName (LogSeverity severity)
constexpr LogCategory tachyon::Diagnostics::MakeLogCategory (std::string_view staticName)
 A category named staticName, which must be a static string.
template<typename T>
LogArg tachyon::Diagnostics::MakeLogArg (const T &value)
std::string_view tachyon::Diagnostics::LogArgText (const LogRecord &record, const LogArg &arg)
size_t tachyon::Diagnostics::FormatLogMessage (const LogRecord &record, std::span< char > out)
 Writes the template with its arguments substituted, NUL-terminated and truncated to out.
void tachyon::Diagnostics::SetLogConsoleOutput (bool enabled)
 Turns the built-in stdout/stderr/debugger sink on or off (on by default). [AnyThread].
bool tachyon::Diagnostics::AddLogSink (LogSinkFn sink, void *context)
 Registers sink, called with every record and context.
void tachyon::Diagnostics::RemoveLogSink (LogSinkFn sink, void *context)
 Unregisters a sink added with the same sink and context. [MainThread].
void tachyon::Diagnostics::LogMessage (LogCategory category, LogSeverity severity, std::string_view messageTemplate, std::span< const LogArg > args, const char *file="", uint32_t line=0)
 Emits one record. Prefer the TACHYON_LOG_* macros, which add the source location. [AnyThread].
void tachyon::Diagnostics::ReportMisuse (LogCategory category, const char *message)
 API misuse (an unbalanced Begin/End, a call outside its frame, ...) is reported, not fatal: the caller recovers and the app carries on.
void tachyon::Diagnostics::ResetMisuseReports ()
 Lets every misuse be reported again (tests). [AnyThread].
uint64_t tachyon::Diagnostics::LatestLogSequence ()
 Sequence number of the newest record (0 before the first). [AnyThread].
uint32_t tachyon::Diagnostics::CopyRecentLogRecords (std::span< LogRecord > out)
 Copies up to out.size() of the most recent records, oldest first.
template<typename... Args>
void tachyon::Diagnostics::Log (LogCategory category, LogSeverity severity, const char *file, uint32_t line, std::string_view messageTemplate, const Args &... args)
 Emits a record with args (at most kMaxLogArgs) for the {} in messageTemplate; what the TACHYON_LOG_* macros call.

Variables

constexpr int tachyon::Diagnostics::kMaxLogArgs = 4
constexpr int tachyon::Diagnostics::kLogTextCapacity = 384
 bytes shared by a record's text arguments
constexpr int tachyon::Diagnostics::kLogRingCapacity = 1024
constexpr int tachyon::Diagnostics::kMaxLogSinks = 8
void tachyon::Diagnostics::SetMinimumLogSeverity (LogSeverity severity)
 Records below the minimum severity are dropped before any work is done.
LogSeverity tachyon::Diagnostics::GetMinimumLogSeverity ()
 Records below the minimum severity are dropped before any work is done.

Macro Definition Documentation

◆ TACHYON_LOG_TRACE

#define TACHYON_LOG_TRACE ( category,
... )
Value:
void Log(LogCategory category, LogSeverity severity, const char *file, uint32_t line, std::string_view messageTemplate, const Args &... args)
Emits a record with args (at most kMaxLogArgs) for the {} in messageTemplate; what the TACHYON_LOG_* ...
Definition gui_logging.h:170
@ Trace
Definition gui_logging.h:28

◆ TACHYON_LOG_DEBUG

#define TACHYON_LOG_DEBUG ( category,
... )
Value:
@ Debug
Definition gui_logging.h:28

◆ TACHYON_LOG_INFO

#define TACHYON_LOG_INFO ( category,
... )
Value:
@ Info
Definition gui_logging.h:28

◆ TACHYON_LOG_WARNING

#define TACHYON_LOG_WARNING ( category,
... )
Value:
@ Warning
Definition gui_logging.h:28

◆ TACHYON_LOG_ERROR

#define TACHYON_LOG_ERROR ( category,
... )
Value:
@ Error
Definition gui_logging.h:28

◆ TACHYON_LOG_CRITICAL

#define TACHYON_LOG_CRITICAL ( category,
... )
Value:
@ Critical
Definition gui_logging.h:28