Agrarsense
|
#include <LogFile.h>
Public Member Functions | |
ULogFile () | |
~ULogFile () | |
void | Create (const FString &FileNameWithoutExtension, FLogFileSettings Settings) |
void | Write (const FString &Text) |
void | Close () |
void | Clear () |
void | Destroy () |
void | OpenFilePath () |
FString | GetLogFilePath () |
Static Public Member Functions | |
static ULogFile * | CreateLogFile (const FString &FileNameWithoutExtension, FLogFileSettings Settings=FLogFileSettings()) |
Private Member Functions | |
void | WriteQueuedMessages () |
void | WriteToFile (const FString &Text, bool UseTimestamp) |
Private Attributes | |
TArray< FString > | MessageQueue |
FLogFileSettings | CurrentSettings |
FString | FilePath |
std::ofstream | LogFileStream |
LogFile is a Blueprintable class that allows .txt file creation and writing into it. The .txt file is created in the ROOT/Data/ directory.
ULogFile::ULogFile | ( | ) |
Definition at line 29 of file LogFile.cpp.
ULogFile::~ULogFile | ( | ) |
Definition at line 34 of file LogFile.cpp.
References Close(), and WriteQueuedMessages().
void ULogFile::Clear | ( | ) |
Clear the file if it exists.
Definition at line 161 of file LogFile.cpp.
References FilePath.
Referenced by Create().
void ULogFile::Close | ( | ) |
Close the file if it's open.
Definition at line 153 of file LogFile.cpp.
References LogFileStream.
Referenced by Destroy(), and ~ULogFile().
void ULogFile::Create | ( | const FString & | FileNameWithoutExtension, |
FLogFileSettings | Settings | ||
) |
Create the log file.
FileNameWithoutExtension | The name of the log file without extension. |
Settings | The settings for creating the log file. |
Definition at line 40 of file LogFile.cpp.
References Append, Clear(), CreateUnique, CurrentSettings, FLogFileSettings::FileCreationOptions, FLogFileSettings::FilePath, FilePath, UAgrarsensePaths::GetDataFolder(), FLogFileSettings::OverrideFilePath, and Overwrite.
Referenced by ASensor::CreateLogFile(), ACamera::CreateLogFile(), and CreateLogFile().
|
static |
Static way of creating a ULogFile instance and creating the file at the same time.
FileNameWithoutExtension | The name of the log file without extension. |
Settings | (Optional) The settings for creating the log file. Default is an empty settings object. |
Definition at line 17 of file LogFile.cpp.
References Create().
Referenced by SimulatorLog::Create().
void ULogFile::Destroy | ( | ) |
Start destroying this UObject.
Definition at line 170 of file LogFile.cpp.
References Close(), and WriteQueuedMessages().
Referenced by ASensor::EndPlay(), and SimulatorLog::Shutdown().
|
inline |
void ULogFile::OpenFilePath | ( | ) |
Open the file explorer at the path of the file.
Definition at line 180 of file LogFile.cpp.
References FilePath, and UFileUtilities::OpenFileExplorer().
void ULogFile::Write | ( | const FString & | Text | ) |
Write a message to the file.
Text | The text message to write to the log file. |
Definition at line 119 of file LogFile.cpp.
References CurrentSettings, FilePath, FLogFileSettings::FileWriteOptions, MessageQueue, Queue, FLogFileSettings::QueueLength, FLogFileSettings::Timestamp, WriteQueuedMessages(), and WriteToFile().
Referenced by SimulatorLog::Log(), and ASensor::WriteToLogFile().
|
private |
Write any queued messages to .txt file.
Definition at line 185 of file LogFile.cpp.
References CurrentSettings, FilePath, FLogFileSettings::KeepFileOpen, LogFileStream, MessageQueue, and WriteToFile().
Referenced by Destroy(), Write(), and ~ULogFile().
|
private |
Actual method where text is written to the .txt file.
Text | The text message to write to the log file. |
UseTimestamp | Indicates whether to include a timestamp in the log message. |
Definition at line 216 of file LogFile.cpp.
References CurrentSettings, FilePath, FLogFileSettings::KeepFileOpen, LogFileStream, and FLogFileSettings::Timestamp.
Referenced by Write(), and WriteQueuedMessages().
|
private |
Definition at line 145 of file LogFile.h.
Referenced by Create(), Write(), WriteQueuedMessages(), and WriteToFile().
|
private |
Definition at line 147 of file LogFile.h.
Referenced by Clear(), Create(), OpenFilePath(), Write(), WriteQueuedMessages(), and WriteToFile().
|
private |
Definition at line 149 of file LogFile.h.
Referenced by Close(), WriteQueuedMessages(), and WriteToFile().
|
private |
Definition at line 143 of file LogFile.h.
Referenced by Write(), and WriteQueuedMessages().