Slate.LogPaintedText

Slate.LogPaintedText

#Overview

name: Slate.LogPaintedText

This variable is created as a Console Variable (cvar).

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.LogPaintedText is to enable logging of all visible text that is painted in the Unreal Engine’s Slate UI system. This setting variable is primarily used for debugging and development purposes within the Slate rendering system.

Unreal Engine subsystems that rely on this setting variable include:

  1. The Slate UI system
  2. The Text Rendering system
  3. The Internationalization system

The value of this variable is set through a console variable (CVar) named “Slate.LogPaintedText”. It is initialized as false and can be toggled at runtime.

The associated variable GLogPaintedText interacts directly with Slate.LogPaintedText. They share the same value, with GLogPaintedText being the actual boolean variable used in the code to check if text logging is enabled.

Developers must be aware of the following when using this variable:

  1. It is only available in non-shipping builds (#if !UE_BUILD_SHIPPING).
  2. Enabling this variable will log all visible text, which can generate a large amount of log data.
  3. The logged text represents the full text to be painted, not the truncated or clipped version based on UI constraints.

Best practices when using this variable include:

  1. Use it temporarily for debugging purposes and disable it when not needed to avoid performance overhead.
  2. Be cautious when enabling it in performance-sensitive scenarios, as it may impact frame rates.
  3. Use in conjunction with other debugging tools to isolate text-related issues in the UI.

Regarding the associated variable GLogPaintedText:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Rendering/DrawElementTypes.cpp:367

Scope (from outer to inner):

file
namespace    UE::Slate::Private

Source code excerpt:

	bool GLogPaintedText = false;
	FAutoConsoleVariableRef LogPaintedTextRef(
		TEXT("Slate.LogPaintedText"),
		GLogPaintedText,
		TEXT("If true, all text that is visible to the user will be logged when it is painted. This will log the full text to be painted, not the truncated or clipped version based on UI constraints.")
	);
}
#endif

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Internationalization/TextLocalizationManager.cpp:111

Scope (from outer to inner):

file
namespace    TextLocalizationManager
function     FString KeyifyTextId

Source code excerpt:

{
	// We want to show the identity in terms of key, namespace. This is to try and fit into the constraints of UI text blocks and at least let the key component be visible to easily identify a piece of text.
	// If the key/namespace pair is too long, the Slate.LogPaintedText cvar can be used to see the entire thing.
	return FString::Printf(TEXT("%s, %s"), TextId.GetKey().GetChars(), TextId.GetNamespace().GetChars());
}
}

enum class ERequestedCultureOverrideLevel : uint8
{

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Text/SlateTextRun.cpp:78

Scope (from outer to inner):

file
function     int32 FSlateTextRun::OnPaint

Source code excerpt:

{
#if !UE_BUILD_SHIPPING
	static const auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("Slate.LogPaintedText"));
	if (CVar->GetBool())
	{
		UE_LOG(LogSlate, Log, TEXT("FSlateTextRun: '%s'."), **Text);
	}
#endif
	const ESlateDrawEffect DrawEffects = bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;

#Associated Variable and Callsites

This variable is associated with another variable named GLogPaintedText. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Rendering/DrawElementTypes.cpp:365

Scope (from outer to inner):

file
namespace    UE::Slate::Private

Source code excerpt:

namespace UE::Slate::Private
{
	bool GLogPaintedText = false;
	FAutoConsoleVariableRef LogPaintedTextRef(
		TEXT("Slate.LogPaintedText"),
		GLogPaintedText,
		TEXT("If true, all text that is visible to the user will be logged when it is painted. This will log the full text to be painted, not the truncated or clipped version based on UI constraints.")
	);
}
#endif

void FSlateDrawElement::MakeText( FSlateWindowElementList& ElementList, uint32 InLayer, const FPaintGeometry& PaintGeometry, const FString& InText, const int32 StartIndex, const int32 EndIndex, const FSlateFontInfo& InFontInfo, ESlateDrawEffect InDrawEffects, const FLinearColor& InTint )

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Rendering/DrawElementTypes.cpp:384

Scope (from outer to inner):

file
function     void FSlateDrawElement::MakeText

Source code excerpt:

	}
#if !UE_BUILD_SHIPPING
	if (UE::Slate::Private::GLogPaintedText)
	{
		UE_LOG(LogSlate, Log, TEXT("MakeText: '%s'."), *InText);
	}
#endif
	FSlateTextElement& Element = ElementList.AddUninitialized<EElementType::ET_Text>();

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Rendering/DrawElementTypes.cpp:419

Scope (from outer to inner):

file
function     void FSlateDrawElement::MakeText

Source code excerpt:

	}
#if !UE_BUILD_SHIPPING
	if (UE::Slate::Private::GLogPaintedText)
	{
		UE_LOG(LogSlate, Log, TEXT("MakeText: '%s'."), *InText);
	}
#endif
	FSlateTextElement& Element = ElementList.AddUninitialized<EElementType::ET_Text>();