TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::Diagnostics Namespace Reference

Classes

struct  LogArg
 One argument. More...
struct  LogCategory
 A subsystem's log category. More...
struct  LogRecord
 One message as sinks and CopyRecentLogRecords see it. More...
struct  ProfileSample
 One finalized node, depth-first. Durations are windowed averages (~4 updates/s). More...
class  ScopedTimer
 Times its own lifetime as a scope; a disabled profiler costs one branch. More...
struct  ScopeLocation
 Per-call-site descriptor, static at each TACHYON_PROFILE_SCOPE site. More...

Typedefs

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

Enumerations

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

Functions

const char * LogSeverityName (LogSeverity severity)
constexpr LogCategory MakeLogCategory (std::string_view staticName)
 A category named staticName, which must be a static string.
template<typename T>
LogArg MakeLogArg (const T &value)
std::string_view LogArgText (const LogRecord &record, const LogArg &arg)
size_t FormatLogMessage (const LogRecord &record, std::span< char > out)
 Writes the template with its arguments substituted, NUL-terminated and truncated to out.
void SetLogConsoleOutput (bool enabled)
 Turns the built-in stdout/stderr/debugger sink on or off (on by default). [AnyThread].
bool AddLogSink (LogSinkFn sink, void *context)
 Registers sink, called with every record and context.
void RemoveLogSink (LogSinkFn sink, void *context)
 Unregisters a sink added with the same sink and context. [MainThread].
void 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 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 ResetMisuseReports ()
 Lets every misuse be reported again (tests). [AnyThread].
uint64_t LatestLogSequence ()
 Sequence number of the newest record (0 before the first). [AnyThread].
uint32_t CopyRecentLogRecords (std::span< LogRecord > out)
 Copies up to out.size() of the most recent records, oldest first.
template<typename... Args>
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_* macros call.
ProfilerCollector & MainThreadCollector ()
bool IsProfilingEnabled ()
void SetProfilingEnabled (bool enabled)
void Reset (ProfilerCollector &collector)
 Discards all nodes and history; cached scope sites re-resolve.
void EnterScope (ProfilerCollector &collector, uint64_t nameHash, const char *name, bool isWait=false, const char *file="", int line=0) noexcept
 Uncached scope entry, for direct use and tests; pair with ExitScope.
std::span< const ProfileSample > LastFrameSamples (const ProfilerCollector &collector)
 The nodes of the last finalized frame, depth-first. Valid until the next EndFrame.
double LastFrameTotalMs (const ProfilerCollector &collector)
 Smoothed total of the root scope(s): the frame total, in milliseconds.

Variables

constexpr int kMaxLogArgs = 4
constexpr int kLogTextCapacity = 384
 bytes shared by a record's text arguments
constexpr int kLogRingCapacity = 1024
constexpr int kMaxLogSinks = 8
void SetMinimumLogSeverity (LogSeverity severity)
 Records below the minimum severity are dropped before any work is done.
LogSeverity GetMinimumLogSeverity ()
 Records below the minimum severity are dropped before any work is done.
void BeginFrame (ProfilerCollector &collector)
 Frame boundaries: call once each, around all scopes for the frame.
void EndFrame (ProfilerCollector &collector)
 Frame boundaries: call once each, around all scopes for the frame.
void EnterScope (ProfilerCollector &collector, ScopeLocation &loc) noexcept
 Cached scope entry / exit, as the macros use.
void ExitScope (ProfilerCollector &collector) noexcept
 Cached scope entry / exit, as the macros use.