Logo: Ue Logging And Assertions

Ue Logging And Assertions

Communautéit
kevinpbuckley
ue-logging-and-assertions

Add structured logging and runtime checks to Unreal C++ — UE_LOG with custom log categories (DECLARE_LOG_CATEGORY_EXTERN/DEFINE_LOG_CATEGORY), all seven verbosity levels (Fatal/Error/Warning/Display/Log/Verbose/VeryVerbose), structured named-field logging with UE_LOGFMT, the assertion families check/checkf (halts, compiled out in shipping), verify/verifyf (expression always evaluates), ensure/ensureMsgf/ensureAlways (non-fatal, reports once), and the FMsg/FDebug helpers. Use when adding diagnostics to gameplay or engine code, defining a dedicated log category for a module or feature, choosing between crashing and recovering on a bad assumption, printing transient values to screen during PIE, filtering log output by category, or debugging shipping-only crashes where ensures would help.

Iwwersiicht

Editeurkevinpbuckley
Repositoryunreal-engine-skills
Skill-Nummue-logging-and-assertions
Stären
89
Forks
9
Matgeliwwert Dateien
3
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 3 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    kevinpbuckley huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Ue Logging And Assertions an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-logging-and-assertions
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kevinpbuckley/unreal-engine-skills.git /tmp/unreal-engine-skills
mkdir -p .claude/skills
cp -r /tmp/unreal-engine-skills/skills/core/ue-logging-and-assertions .claude/skills/ue-logging-and-assertions
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Ue Logging And Assertions an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Ue Logging And Assertions automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Ue Logging And Assertions net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Logging & assertions

Good diagnostics make UE bugs findable in minutes rather than hours. Use log categories (not LogTemp), pick the right verbosity so logs stay scannable, and choose check vs ensure deliberately — one halts, the other reports and continues.

When to use this skill

  • Defining a log category for a new game module or feature subsystem.
  • Adding UE_LOG / UE_LOGFMT calls with the right verbosity for the context.
  • Choosing between check, verify, and ensure for a given assumption.
  • Deciding whether a bad state should crash the program or just report.
  • Filtering or silencing verbose logs per-category at runtime or in builds.

Log categories

Every UE_LOG call names a category. Use the built-in LogTemp for quick prototyping; give each module its own category in production so Output Log filtering works.

Declare in a header, define once in a .cpp:

cpp
// MyFeature.h  (or a dedicated Logging.h for the module)
DECLARE_LOG_CATEGORY_EXTERN(LogMyFeature, Log, All);
//                                         ^--- default runtime verbosity
//                                               ^--- compile-time maximum (All = keep everything)

// MyFeature.cpp
DEFINE_LOG_CATEGORY(LogMyFeature);

DECLARE_LOG_CATEGORY_EXTERN generates an extern struct; DEFINE_LOG_CATEGORY provides the definition. A file-private category uses DEFINE_LOG_CATEGORY_STATIC and needs no header declaration — appropriate for a single .cpp implementation file.

The compile-time maximum (All above) determines which verbosity levels are compiled in. Setting it to Warning strips Log/Verbose/VeryVerbose calls at compile time in that category, even in debug builds. All is the standard choice; tighten only for hot-path code.

See references/log-categories-and-verbosity.md for the full verbosity table, runtime console commands, command-line flags, and DEFINE_LOG_CATEGORY_STATIC vs class-static patterns.

UE_LOG — formatted logging

cpp
// Basic usage: category, verbosity, format string (must be TEXT()), then args
UE_LOG(LogMyFeature, Log,     TEXT("Spawned %s at %s"), *Actor->GetName(), *Loc.ToString());
UE_LOG(LogMyFeature, Warning, TEXT("Ammo low: remaining=%d"), Ammo);
UE_LOG(LogMyFeature, Error,   TEXT("Null weapon on %s — skipping fire"), *GetName());

Format specifiers: %s expects a const TCHAR* — dereference FString with * to get one. %d int32, %f float/double, %p pointer. Using an FString directly (without *) as %s is the most common logging bug.

UE_CLOG(Condition, Category, Verbosity, Format, ...) is the conditional variant — the format is only evaluated when Condition is true.

UE_LOGFMT — structured logging (UE 5.2+)

UE_LOGFMT records a structured log event with named fields, enabling machine-readable output and richer tooling. Requires #include "Logging/StructuredLog.h".

cpp
#include "Logging/StructuredLog.h"

// Positional: values map left-to-right to {field} placeholders in format
UE_LOGFMT(LogMyFeature, Warning, "Weapon '{Name}' fired with {Ammo} rounds left",
    *WeaponName, AmmoCount);

// Named: order is irrelevant; extra fields are allowed
UE_LOGFMT(LogMyFeature, Warning, "Weapon '{Name}' fired with {Ammo} rounds left",
    ("Name", *WeaponName), ("Ammo", AmmoCount), ("ActorTag", *GetName()));

Field names must match [A-Za-z0-9_]+ and be unique within the call. Do not mix positional and named styles in the same call. Supports up to 16 fields via UE_LOGFMT; use UE_LOGFMT_EX with UE_LOGFMT_FIELD("Name", Value) wrappers for more.

See references/structured-logging.md for the field serialization protocol, UE_LOG_CONTEXT, FLogRecord, and thread-local context scopes.

Verbosity levels

From most to least severe (verbosity Fatal = highest priority):

LevelOutputTypical use
FatalCrashes immediately, always, even with NO_LOGGINGTruly unrecoverable error
ErrorConsole + log file, highlighted redWrong state that will cause visible malfunction
WarningConsole + log file, highlighted yellowRecoverable but unexpected; code worked around it
DisplayConsole + log fileInfrequent informational events (startup, asset loads)
LogLog file only (not console)Normal operational info; may be noisy
VerboseLog file if category enabledDetailed trace, disabled by default
VeryVerboseLog file if category enabledPer-frame or very-high-frequency trace

Runtime adjustment without restarting: Log LogMyFeature Verbose (console) or -LogCmds="LogMyFeature Verbose" (command line). The runtime level cannot exceed the compile-time maximum baked into the category.

Assertions

Three families — choose based on whether the expression must run and what happens on failure:

MacroDev behaviorShippingExpression runs in shipping?
check(expr)halts + callstackcompiled outno
checkf(expr, fmt, ...)halts + message + callstackcompiled outno
checkSlow(expr)halts in Debug onlycompiled outno
checkNoEntry()halts if hitcompiled out—
verify(expr)halts if falseexpression runs, no haltyes
verifyf(expr, fmt, ...)halts + messageexpression runs, no haltyes
ensure(expr)logs + callstack once, continuesexpression runs, no reportyes
ensureMsgf(expr, fmt, ...)logs + message + callstack once, continuesexpression runsyes
ensureAlways(expr)logs + callstack every timeexpression runsyes
cpp
// check: hard invariant — continuing is unsafe if false
check(Weapon != nullptr);
checkf(Index >= 0 && Index < Count, TEXT("Index %d out of range [0, %d)"), Index, Count);

// verify: side-effecting call that must both run and succeed
verify((Mesh = GetRenderMesh()) != nullptr);  // GetRenderMesh() runs even in shipping

// ensure: unexpected-but-recoverable; keeps editor alive, submits crash report once
if (!ensure(Target != nullptr)) { return; }
ensureMsgf(bInitialized, TEXT("%s used before Init()"), *GetName());

// checkNoEntry: unreachable code sentinel
default: checkNoEntry(); break;

Rule of thumb for gameplay code: prefer ensure over check. An editor that continues running lets you investigate the bad state in the Output Log and debugger; a crash destroys that context. Reserve check for truly invariant conditions where execution past the failure would corrupt state or crash anyway.

See references/assertions.md for compile-flag mechanics (DO_CHECK, DO_ENSURE, USE_CHECKS_IN_SHIPPING), FDebug helpers, and LowLevelFatalError.

On-screen debug messages (PIE only)

cpp
if (GEngine)
{
    GEngine->AddOnScreenDebugMessage(
        -1,              // key: -1 = no deduplication; use a stable int to overwrite the same slot
        5.f,             // seconds to display
        FColor::Yellow,
        FString::Printf(TEXT("HP: %d / %d"), Hp, MaxHp));
}

Key -1 lets messages pile up; pass a stable non-negative integer (e.g. GetUniqueID()) to overwrite the same line each tick. Gate with #if !UE_BUILD_SHIPPING or remove before ship — this is PIE debugging only.

Where logs go

DestinationHow to reach it
Editor Output LogWindow › Output Log; filter by category name
Log file on disk<Project>/Saved/Logs/<ProjectName>.log
Console (in-game)~ key; Log CategoryName Verbosity to change level

Gotchas

  • %s with an FString without * — passes the FString object as a vararg, which reads garbage bytes; always write *MyString.
  • check in shipping is compiled to nothing — never put required side effects inside check(expr). If the call must execute, use verify(expr).
  • ensure fires only once per call site in a session by default — it will not spam, but a second hit in the same run is silently skipped. Use ensureAlways if every occurrence matters.
  • Logging in a tick at Log or Warning spams the log file and slows the editor; use Verbose/VeryVerbose for per-frame data, or UE_CLOG to conditionalize.
  • Compile-time verbosity too low — if your DECLARE_LOG_CATEGORY_EXTERN sets CompileTimeVerbosity to Warning, UE_LOG(Cat, Verbose, ...) is silently stripped at compile time regardless of runtime settings.
  • Fatal verbosity always runs, even when NO_LOGGING is defined — it maps to LowLevelFatalError which crashes unconditionally.
  • UE_LOGFMT requires the header — #include "Logging/StructuredLog.h"; missing it produces an undefined-macro error, not a useful diagnostic.

Version notes

  • UE_LOGFMT and UE_LOG_CONTEXT were introduced in UE 5.2 and are stable through 5.8.
  • The FStaticEnsureRecord per-call-site mechanism (atomic bGEnsureHasExecuted) replaced a simpler boolean in UE 5.x; the user-facing macro signatures are unchanged.
  • LowLevelFatalErrorHandler was deprecated in 5.7; use LowLevelFatalError (macro).

Cross-references

  • ue-debugging-techniques — DrawDebug*, Visual Logger, Gameplay Debugger, native debugger usage; these complement logging for spatial and timeline debugging.

References & source material

Engine source (UE 5.8, under Engine/Source/Runtime/Core/Public/):

  • Logging/LogMacros.h — UE_LOG:278, UE_CLOG:325, FMsg::Logf:62, FMsg::Logf_Internal:72.
  • Logging/LogCategory.h — DECLARE_LOG_CATEGORY_EXTERN:133, DEFINE_LOG_CATEGORY:140, DEFINE_LOG_CATEGORY_STATIC:150 (moved here from LogMacros.h in 5.8).
  • Logging/LogVerbosity.h — ELogVerbosity::Type enum:16 (Fatal:22 through VeryVerbose:52, All:56, VerbosityMask:58).
  • Logging/LogCategory.h — FLogCategoryBase:21, FLogCategory<> template:86, IsSuppressed:45, SetVerbosity:59.
  • Logging/StructuredLog.h — UE_LOGFMT:46, UE_LOGFMT_EX:64, UE_LOG_CONTEXT:143, FLogRecord:181, SerializeForLog:297.
  • Misc/AssertionMacros.h — check:229, verify:226, checkf:259, verifyf:256, checkSlow:333, checkNoEntry:283, ensure:461, ensureMsgf:462, ensureAlways:463, ensureAlwaysMsgf:464, FDebug:68, LowLevelFatalError:591.

Official docs (UE 5.8, fetched and confirmed):

Deep-dive references in this skill:

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Ue Logging And Assertions?

Add structured logging and runtime checks to Unreal C++ — UE_LOG with custom log categories (DECLARE_LOG_CATEGORY_EXTERN/DEFINE_LOG_CATEGORY), all seven verbosity levels (Fatal/Error/Warning/Display/Log/Verbose/VeryVerbose), structured named-field logging with UE_LOGFMT, the assertion families check/checkf (halts, compiled out in shipping), verify/verifyf (expression always evaluates), ensure/ensureMsgf/ensureAlways (non-fatal, reports once), and the FMsg/FDebug helpers. Use when adding diagnostics to gameplay or engine code, defining a dedicated log category for a module or feature, choosi...

Firwat Ue Logging And Assertions op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Ue Logging And Assertions besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Ue Logging And Assertions an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-logging-and-assertions an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Ue Logging And Assertions benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Ue Logging And Assertions benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Ue Logging And Assertions domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Ue Logging And Assertions gratis?

kevinpbuckley huet de Skill op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇