Agrarsense
Static Public Member Functions | Static Private Member Functions | Static Private Attributes | Friends | List of all members
SimulatorLog Class Reference

#include <SimulatorLog.h>

Collaboration diagram for SimulatorLog:
Collaboration graph
[legend]

Static Public Member Functions

static void Log (const FString &Message, bool LogToTextFile=true, bool LogToROS=true)
 

Static Private Member Functions

static void Create ()
 
static void Shutdown ()
 

Static Private Attributes

static ULogFileSimulatorLogFile = nullptr
 

Friends

class AAgrarsenseGameModeBase
 

Detailed Description

Static class for logging Simulator messages to console, text file and ROS.

Definition at line 19 of file SimulatorLog.h.

Member Function Documentation

◆ Create()

void SimulatorLog::Create ( )
staticprivate

Create the log file.

Definition at line 41 of file SimulatorLog.cpp.

42{
43 if (!IsValid(SimulatorLogFile))
44 {
45 // Find or create Agrarsense.txt file
46 FLogFileSettings Settings;
49 Settings.QueueLength = 10;
50 Settings.KeepFileOpen = false;
51 SimulatorLogFile = ULogFile::CreateLogFile("Agrarsense", Settings);
52 }
53}
static ULogFile * SimulatorLogFile
Definition: SimulatorLog.h:47
static ULogFile * CreateLogFile(const FString &FileNameWithoutExtension, FLogFileSettings Settings=FLogFileSettings())
Definition: LogFile.cpp:17
bool KeepFileOpen
Definition: LogFile.h:42
FFileWriteOptions FileWriteOptions
Definition: LogFile.h:45
int32 QueueLength
Definition: LogFile.h:48
FFileCreationOptions FileCreationOptions
Definition: LogFile.h:36

References Append, ULogFile::CreateLogFile(), FLogFileSettings::FileCreationOptions, FLogFileSettings::FileWriteOptions, FLogFileSettings::KeepFileOpen, Queue, FLogFileSettings::QueueLength, and SimulatorLogFile.

Referenced by AAgrarsenseGameModeBase::SpawnNeededActorsInitGame().

◆ Log()

void SimulatorLog::Log ( const FString &  Message,
bool  LogToTextFile = true,
bool  LogToROS = true 
)
static

Logs a message.

Parameters
MessageThe message to log.
LogToTextFileWhether to log to a text file.
LogToROSWhether to log to ROS.

Definition at line 14 of file SimulatorLog.cpp.

15{
16 if (!IsInGameThread())
17 {
18 // If not in game thread, call itself back within the game thread.
19 AsyncTask(ENamedThreads::GameThread, [Message, LogToTextFile, LogToROS]()
20 {
21 Log(Message, LogToTextFile, LogToROS);
22 });
23 return;
24 }
25
26 if (SimulatorLogFile && SimulatorLogFile->IsValidLowLevel() && LogToTextFile)
27 {
28 SimulatorLogFile->Write(Message);
29 }
30
31 if (LogToROS)
32 {
34 }
35
36#if WITH_EDITOR
37 UE_LOG(LogTemp, Warning, TEXT("SimulatorLog.cpp: %s"), *Message);
38#endif
39}
static void Log(const FString &Message, bool LogToTextFile=true, bool LogToROS=true)
static void SendMessage(const FString &Message)
Definition: InfoTopic.cpp:129
void Write(const FString &Text)
Definition: LogFile.cpp:119

References Log(), UInfoTopic::SendMessage(), SimulatorLogFile, and ULogFile::Write().

Referenced by ACamera::AddPostProcessingMaterial(), ASensor::BeginPlay(), AOverlapSensor::BuildAndSendMessage(), UAgrarsenseSettings::ChangeMapByName(), ALidar::ChangeParameters(), ASensor::CreateROSTopic(), UAssetLibrary::DestroyAllWalkers(), ADeletionVolume::DestroyOverlappingActors(), AAgrarsenseGameModeBase::EndPlay(), ASensor::EndPlay(), USimulatorJsonExporter::ExportInstancedActorsToJSON(), USimulatorJsonExporter::ExportSensorToJSON(), USimulatorJsonExporter::ExportVehicleAndSensorsToJSON(), USimulatorJsonExporter::ExportWalkerToJSON(), USimulatorJsonExporter::ExportWeatherToJSON(), UROSCommands::HandlePrintAvailableCommands(), UROSCommands::HandlePrintMaps(), UROSCommands::HandleTryDestroyObjectByID(), Log(), ACollisionSensor::OnCollisionEvent(), USimulatorJsonParser::ParseAndOperateJSONFile(), USimulatorJsonParser::ParseAndSetSemanticColors(), UROSCommands::ParseIncomingMessage(), UAgrarsenseSettings::PauseSimulation(), UROSCommands::PrintActorInformation(), IActorInformation::PrintAllIds(), UAgrarsenseGameInstance::ROSBridgeConnected(), UAgrarsenseGameInstance::ROSBridgeDisconnected(), ACamera::SaveImageToDisk(), UAgrarsenseSettings::SetGlobalTimeDilation(), AOverlapSensor::SetOverlapBounds(), AOverlapSensor::SetOverlapRelativePosition(), UAgrarsenseSettings::SetQualityLevel(), UAgrarsenseSettings::SetUltraWithRaytracingLevel(), UAgrarsenseSettings::SetWorldRendering(), USimulatorLogFunctionLibrary::SimulatorLog(), AAgrarsenseGameModeBase::SpawnNeededActorsInitGame(), USimulatorJsonParser::SpawnSensorWorld(), USimulatorJsonParser::SpawnWalker(), UAssetLibrary::SpawnWalker(), and UAgrarsenseSettings::UnPauseSimulation().

◆ Shutdown()

void SimulatorLog::Shutdown ( )
staticprivate

Destroy the log file.

Definition at line 55 of file SimulatorLog.cpp.

56{
57 if (IsValid(SimulatorLogFile))
58 {
60 SimulatorLogFile = nullptr;
61 }
62}
void Destroy()
Definition: LogFile.cpp:170

References ULogFile::Destroy(), and SimulatorLogFile.

Referenced by AAgrarsenseGameModeBase::EndPlay().

Friends And Related Function Documentation

◆ AAgrarsenseGameModeBase

friend class AAgrarsenseGameModeBase
friend

Definition at line 34 of file SimulatorLog.h.

Member Data Documentation

◆ SimulatorLogFile

ULogFile * SimulatorLog::SimulatorLogFile = nullptr
staticprivate

Definition at line 47 of file SimulatorLog.h.

Referenced by Create(), Log(), and Shutdown().


The documentation for this class was generated from the following files: