Include the details needed to reproduce a failure
A dedicated category plus the item, quantity, and actor makes this rejection searchable.
InventoryComponent.cppcpp
DEFINE_LOG_CATEGORY_STATIC(LogInventory, Log, All);
bool UInventoryComponent::TryAddItem(
const UItemDefinition& Item,
const int32 Quantity)
{
if (Quantity <= 0)
{
UE_LOG(
LogInventory,
Warning,
TEXT("Rejected %s with quantity %d on %s"),
*Item.GetName(),
Quantity,
*GetNameSafe(GetOwner()));
return false;
}
return InsertItem(Item, Quantity);
}- Why
- You can enable
LogInventorywithout turning every system up toVerbose. The message also records which value failed and where it happened. - Costs
- Logs in frequent paths still cost formatting and storage when enabled. Use
VerboseorVeryVerbosefor detail and reserve warnings for actionable faults. - Instead
- Use
ensurefor a recoverable invariant. Visual Logger is better for spatial gameplay problems, while Unreal Insights is built for timing.

