ue-logging-and-assertions

Implements structured logging and runtime assertions in Unreal Engine C++ code.

55|5|Updated Mar 26, 2026
One-click install
npx skills add https://github.com/kevinpbuckley/unreal-engine-skills --skill ue-logging-and-assertions-kevinpbuckley
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ue-logging-and-assertions
Source: https://github.com/kevinpbuckley/unreal-engine-skills/tree/main/skills/core/ue-logging-and-assertions
Command: npx skills add https://github.com/kevinpbuckley/unreal-engine-skills --skill ue-logging-and-assertions-kevinpbuckley

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Unreal C++ code without proper diagnostics makes bugs hard to find: developers misuse log categories, pick wrong verbosity levels, pass FString without dereferencing to %s, or choose check when ensure would keep the editor alive. This Skill provides the correct patterns for UE_LOG, UE_LOGFMT, and the check/verify/ensure assertion families grounded in UE 5.8 engine source. ## Core Features & Use Cases - Log category setup: Declare and define custom log categories with DECLARE_LOG_CATEGORY_EXTERN/DEFINE_LOG_CATEGORY, including file-static and class-static variants, with correct default and compile-time verbosity. - Structured logging with UE_LOGFMT: Emit machine-readable log events with positional or named fields, UE_LOG_CONTEXT thread-local scopes, and custom SerializeForLog overloads. - Assertion selection: Choose between check (halts, compiled out in shipping), verify (expression always runs), and ensure (non-fatal, reports once) based on whether continuing after failure is safe. - Use Case: While adding diagnostics to a new gameplay module, an agent defines a dedicated LogMyFeature category, adds UE_LOGFMT calls with named fields for weapon fire events, and guards nullable pointers with ensureMsgf so the editor stays alive during PIE debugging. ## Quick Start Add a custom log category and appropriate check/ensure assertions to my Unreal C++ gameplay class using this skill.

Frequently Asked Questions about ue-logging-and-assertions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a custom log category in Unreal Engine C++?

Declare the category in a header with DECLARE_LOG_CATEGORY_EXTERN(LogMyFeature, Log, All) and define it once in a .cpp file with DEFINE_LOG_CATEGORY(LogMyFeature). For a category private to one .cpp file, use DEFINE_LOG_CATEGORY_STATIC with no header declaration.

What is the difference between check, verify, and ensure in Unreal Engine?

check halts execution and is compiled out in shipping builds, so its expression never runs there. verify also halts on failure but its expression always evaluates, even in shipping. ensure is non-fatal: it logs a callstack once per call site and lets execution continue, making it preferred for gameplay code.

How does UE_LOGFMT structured logging work in Unreal Engine?

UE_LOGFMT records a structured log event with named fields instead of a flat string, requiring #include "Logging/StructuredLog.h". Fields can be positional or named with ("Name", Value) pairs, and UE_LOG_CONTEXT adds thread-local fields automatically to every call in a scope.

Why does my UE_LOG with %s print garbage for an FString?

The %s format specifier expects a const TCHAR*, not an FString object. Passing an FString directly as a vararg reads garbage bytes; always dereference it with the * operator, as in *MyString, when logging.

Can I enable check assertions in Unreal Engine shipping builds?

Yes, set USE_CHECKS_IN_SHIPPING=1 in your Target.cs or build configuration to keep check macros active in shipping. This helps track down shipping-only crashes but carries a performance cost and should not be the default for released products.

Why does ensure only fire once per call site in Unreal Engine?

ensure deduplicates failures per call site using a static atomic flag keyed by file and line, so the first failure reports and subsequent hits in the same session are silently skipped. Use ensureAlways when every occurrence must be reported.