I might be using AGameInfo
completely wrong, so please feel free to correct me if that’s the issue. In my GameInfo subclass, AMyProjectGameInfo
, I have the following code:
void AMyProjectGameInfo::PreInitializeComponents()
{
Super::PreInitializeComponents();
UE_LOG(Sagittarius, Log, TEXT("HELLO WORLD!!"));
ASagittarius* sag = GetWorld()->SpawnActor();
sag->Encrypt("test");
}
I have added DEFINE_LOG_CATEGORY(Sagittarius);
in MyProject.cpp and DECLARE_LOG_CATEGORY_EXTERN(Sagittarius, Log, Log);
in MyProject.h, everything compiles fine, so it should work. This should not only print the line HELLO WORLD!
, but some underlying log strings that the Encrypt()
function calls.
I was under the impression that PreInitializeComponents()
and PostInitializeComponents()
are analogous to PreBeginPlay()
and PostBeginPlay()
from UDK, so the log should already be open at this time. However, nothing gets printed.
I also tried logging from InitGame()
and PostLogin()
, nothing there either. I didn’t expect there to be any output from InitGame()
since that is likely before the logging system gets initialized.
So what is the problem? And when is the earliest time that we can use the logging system?
EDIT: The relevant portion from my log is:
[0002.61] LogWorld: Game class is 'MyProjectGameInfo'
[0002.62] LogWorld: Bringing World /Temp/Autosaves//Game/UEDPCLaserMap.TheWorld up for play (0) at 2013.10.11-13.46.10
[0002.62] LogWorld: Bringing up level for play took: 0.002030
[0002.62] LogPlayerController: ClientRestart_Implementation DefaultPawn_0
[0002.62] LogPlayerController: ServerAcknowledgePossession_Implementation DefaultPawn_0
[0002.62] LogLoad: Loading URL /Temp/Autosaves//Game/UEDPCLaserMap?Name=Player: 0.10 seconds
[0002.62] LogInit:Display: Game Engine Initialized.
[0002.62] LogLoad: UGameEngine::Init: 0.96 seconds
[0002.62] LogLoad: Full Startup: 2.62 seconds
[0002.64] LogAssetRegistry: FAssetRegistry took 0.000000 seconds to start up
[0002.69] LogRenderer:Warning: Reallocating scene render targets to support 1280x720.
[0013.36] LogEngine: All Windows Closed
[0013.36] LogWindows: FPlatformMisc::RequestExit(0)
[0014.52] LogHttp: Start Http request. url=https://api.swrve.com/1/session_end?api_key=TWn7EDcoV0xHSxGhYwCd&user=c5f5b374a77b3fd3a5107d152c6d0dc1&app_version=1.4.0.0.1808360
[0014.52] LogHttp: Start Http request. url=http://udkprofiler.epicgames.com/ETAP/SendEvent.1?SessionID={31246674-4F18-7CA8-53A0-82BD39C4A1FE}&AppID=Rocket.Release&AppVersion=1.4.0.0.1808360&UserID=c5f5b374a77b3fd3a5107d152c6d0dc1&EventName=SessionEnd
[0014.52] LogExit: Preparing to exit.
[0014.54] LogExit: Game engine shut down