LogBlueprintComponentInstanceCalls

LogBlueprintComponentInstanceCalls

#Overview

name: LogBlueprintComponentInstanceCalls

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of LogBlueprintComponentInstanceCalls is to enable logging of Blueprint Component instance calls for debugging purposes in Unreal Engine 5.

This setting variable is primarily used in the Actor Construction system of Unreal Engine 5. It’s specifically utilized in the Engine module, as evidenced by its location in the ActorConstruction.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default.

The associated variable CVarLogBlueprintComponentInstanceCalls directly interacts with LogBlueprintComponentInstanceCalls. They share the same value and purpose.

Developers should be aware that this variable is only available in non-shipping builds (#if !UE_BUILD_SHIPPING). It’s intended for debugging and should not be relied upon in production code.

Best practices when using this variable include:

  1. Only enable it when debugging Blueprint Component instance calls.
  2. Be mindful of performance impact when enabled, as it adds additional logging overhead.
  3. Remember to disable it after debugging to avoid unnecessary logging in development builds.

Regarding CVarLogBlueprintComponentInstanceCalls:

This is the actual console variable that controls the logging behavior. It’s an integer variable, where a non-zero value enables logging.

It’s used in two specific functions:

  1. AActor::CreateComponentFromTemplate
  2. AActor::CreateComponentFromTemplateData

When enabled, it logs the creation time of components, including the actor name, component class, component name, and the time taken to create the component.

Developers should use this variable through the console or configuration files to enable/disable logging as needed during development and debugging sessions. It’s important to note that excessive logging can impact performance, so it should be used judiciously.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorConstruction.cpp:1017

Scope: file

Source code excerpt:

#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarLogBlueprintComponentInstanceCalls(
	TEXT("LogBlueprintComponentInstanceCalls"),
	0,
	TEXT("Log Blueprint Component instance calls; debugging."));
#endif

static FName FindFirstFreeName(UObject* Outer, FName BaseName)
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorConstruction.cpp:1016

Scope: file

Source code excerpt:


#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarLogBlueprintComponentInstanceCalls(
	TEXT("LogBlueprintComponentInstanceCalls"),
	0,
	TEXT("Log Blueprint Component instance calls; debugging."));
#endif

static FName FindFirstFreeName(UObject* Outer, FName BaseName)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorConstruction.cpp:1099

Scope (from outer to inner):

file
function     UActorComponent* AActor::CreateComponentFromTemplate

Source code excerpt:


#if !UE_BUILD_SHIPPING
		if (CVarLogBlueprintComponentInstanceCalls.GetValueOnGameThread())
		{
			UE_LOG(LogBlueprint, Log, TEXT("%s: CreateComponentFromTemplate() - %s \'%s\' completed in %.02g ms"), *GetName(), *Template->GetClass()->GetName(), *InName.ToString(), (FPlatformTime::Seconds() - StartTime) * 1000.0);
		}
#endif
	}
	return NewActorComp;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorConstruction.cpp:1177

Scope (from outer to inner):

file
function     UActorComponent* AActor::CreateComponentFromTemplateData

Source code excerpt:


#if !UE_BUILD_SHIPPING
		if (CVarLogBlueprintComponentInstanceCalls.GetValueOnGameThread())
		{
			UE_LOG(LogBlueprint, Log, TEXT("%s: CreateComponentFromTemplateData() - %s \'%s\' completed in %.02g ms"), *GetName(), *TemplateData->ComponentTemplateClass->GetName(), *InName.ToString(), (FPlatformTime::Seconds() - StartTime) * 1000.0);
		}
#endif
	}
	return NewActorComp;