Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FOutputDeviceFile Class Reference

#include <OutputDeviceFile.h>

+ Inheritance diagram for FOutputDeviceFile:
+ Collaboration diagram for FOutputDeviceFile:

Public Member Functions

 FOutputDeviceFile (const TCHAR *InFilename=nullptr, bool bDisableBackup=false, bool bAppendIfExists=false, bool bCreateWriterLazily=true, TFunction< void(const TCHAR *)> FileOpenedCallback=TFunction< void(const TCHAR *)>())
 
 ~FOutputDeviceFile ()
 
void SetFilename (const TCHAR *InFilename)
 
void TearDown () override
 
void Flush () override
 
virtual void Serialize (const TCHAR *Data, ELogVerbosity::Type Verbosity, const class FName &Category, const double Time) override
 
virtual void Serialize (const TCHAR *Data, ELogVerbosity::Type Verbosity, const class FName &Category) override
 
virtual bool CanBeUsedOnAnyThread () const override
 
virtual bool CanBeUsedOnPanicThread () const override
 
void IncludeCategory (const class FName &InCategoryName)
 
const TCHAR * GetFilename () const
 
bool IsOpened () const
 
- Public Member Functions inherited from FOutputDevice
 FOutputDevice ()
 
 FOutputDevice (FOutputDevice &&)=default
 
 FOutputDevice (const FOutputDevice &)=default
 
FOutputDeviceoperator= (FOutputDevice &&)=default
 
FOutputDeviceoperator= (const FOutputDevice &)=default
 
virtual ~FOutputDevice ()=default
 
virtual void Serialize (const TCHAR *V, ELogVerbosity::Type Verbosity, const FName &Category)=0
 
virtual void Serialize (const TCHAR *V, ELogVerbosity::Type Verbosity, const FName &Category, const double Time)
 
virtual void SerializeRecord (const UE::FLogRecord &Record)
 
void SetSuppressEventTag (bool bInSuppressEventTag)
 
FORCEINLINE bool GetSuppressEventTag () const
 
void SetAutoEmitLineTerminator (bool bInAutoEmitLineTerminator)
 
FORCEINLINE bool GetAutoEmitLineTerminator () const
 
virtual void Dump (class FArchive &Ar)
 
virtual bool IsMemoryOnly () const
 
virtual bool CanBeUsedOnMultipleThreads () const
 
void Log (const TCHAR *S)
 
void Log (ELogVerbosity::Type Verbosity, const TCHAR *S)
 
void Log (const FName &Category, ELogVerbosity::Type Verbosity, const TCHAR *Str)
 
void Log (const FString &S)
 
void Log (const FText &S)
 
void Log (ELogVerbosity::Type Verbosity, const FString &S)
 
void Log (const FName &Category, ELogVerbosity::Type Verbosity, const FString &S)
 
template<typename FmtType >
void Logf (const FmtType &Fmt)
 
template<typename FmtType , typename... Types>
FORCEINLINE void Logf (const FmtType &Fmt, Types... Args)
 
template<typename FmtType , typename... Types>
FORCEINLINE void Logf (ELogVerbosity::Type Verbosity, const FmtType &Fmt, Types... Args)
 
template<typename FmtType , typename... Types>
FORCEINLINE void CategorizedLogf (const FName &Category, ELogVerbosity::Type Verbosity, const FmtType &Fmt, Types... Args)
 

Static Public Member Functions

static void CreateBackupCopy (const TCHAR *Filename)
 
static bool IsBackupCopy (const TCHAR *Filename)
 

Private Member Functions

void WriteRaw (const TCHAR *C)
 
bool CreateWriter (uint32 MaxAttempts=32)
 
void WriteByteOrderMarkToArchive (EByteOrderMark ByteOrderMark)
 

Private Attributes

FAsyncWriterAsyncWriter
 
FArchiveWriterArchive
 
TFunction< void(const TCHAR *) OnFileOpenedFn )
 
TCHAR Filename [1024]
 
bool AppendIfExists
 
bool Dead
 
TUniquePtr< FCategoryInclusionInternalCategoryInclusionInternal
 
bool bDisableBackup
 

Additional Inherited Members

- Protected Attributes inherited from FOutputDevice
bool bSuppressEventTag
 
bool bAutoEmitLineTerminator
 

Detailed Description

File output device (Note: Only works if ALLOW_LOG_FILE && !NO_LOGGING is true, otherwise Serialize does nothing).

Definition at line 113 of file OutputDeviceFile.h.

Constructor & Destructor Documentation

◆ FOutputDeviceFile()

FOutputDeviceFile::FOutputDeviceFile ( const TCHAR * InFilename = nullptr,
bool bDisableBackup = false,
bool bAppendIfExists = false,
bool bCreateWriterLazily = true,
TFunction< void(const TCHAR *)> FileOpenedCallback = TFunctionvoid(const TCHAR *)>() )

Constructor, initializing member variables.

Parameters
InFilenameFilename to use, can be nullptr. If null, a file name will be automatically generated. If a filename is specified but cannot be opened because it is already open/used by another process, the implementation will try to generate a new name automatically, until the a file is created or the number of trials exhausted (32).
bDisableBackupIf true, existing files will not be backed up
bCreateWriterLazilyIf true, delay the creation of the file until something needs to be written, otherwise, open it immediatedly.
FileOpenedCallbackIf bound, invoked when the output file is successfully opened, passing the actual filename.

◆ ~FOutputDeviceFile()

FOutputDeviceFile::~FOutputDeviceFile ( )

Destructor to perform teardown

Member Function Documentation

◆ CanBeUsedOnAnyThread()

virtual bool FOutputDeviceFile::CanBeUsedOnAnyThread ( ) const
inlineoverridevirtual
Returns
whether this output device can be used on any thread.

Reimplemented from FOutputDevice.

Definition at line 153 of file OutputDeviceFile.h.

◆ CanBeUsedOnPanicThread()

virtual bool FOutputDeviceFile::CanBeUsedOnPanicThread ( ) const
inlineoverridevirtual
Returns
whether this output device can be used after a panic (crash or fatal error) has been flagged.
Note
The return value is cached by AddOutputDevice because calling this during a panic may fail.

Reimplemented from FOutputDevice.

Definition at line 157 of file OutputDeviceFile.h.

◆ CreateBackupCopy()

static void FOutputDeviceFile::CreateBackupCopy ( const TCHAR * Filename)
static

Creates a backup copy of a log file if it already exists

◆ CreateWriter()

bool FOutputDeviceFile::CreateWriter ( uint32 MaxAttempts = 32)
private

Creates the async writer and its archive. Returns true if successful.

◆ Flush()

void FOutputDeviceFile::Flush ( )
overridevirtual

Flush the write cache so the file isn't truncated in case we crash right after calling this function.

Reimplemented from FOutputDevice.

◆ GetFilename()

const TCHAR * FOutputDeviceFile::GetFilename ( ) const
inline

Returns the filename associated with this output device

Definition at line 173 of file OutputDeviceFile.h.

◆ IncludeCategory()

void FOutputDeviceFile::IncludeCategory ( const class FName & InCategoryName)

Add a category name to our inclusion filter. As soon as one inclusion exists, all others will be ignored

◆ IsBackupCopy()

static bool FOutputDeviceFile::IsBackupCopy ( const TCHAR * Filename)
static

Checks if the filename represents a backup copy of a log file

◆ IsOpened()

bool FOutputDeviceFile::IsOpened ( ) const

◆ Serialize() [1/2]

virtual void FOutputDeviceFile::Serialize ( const TCHAR * Data,
ELogVerbosity::Type Verbosity,
const class FName & Category )
overridevirtual

◆ Serialize() [2/2]

virtual void FOutputDeviceFile::Serialize ( const TCHAR * Data,
ELogVerbosity::Type Verbosity,
const class FName & Category,
const double Time )
overridevirtual

◆ SetFilename()

void FOutputDeviceFile::SetFilename ( const TCHAR * InFilename)

Sets the filename that the output device writes to. If the output device was already writing to a file, closes that file.

◆ TearDown()

void FOutputDeviceFile::TearDown ( )
overridevirtual

Closes output device and cleans up. This can't happen in the destructor as we have to call "delete" which cannot be done for static/ global objects.

Reimplemented from FOutputDevice.

◆ WriteByteOrderMarkToArchive()

void FOutputDeviceFile::WriteByteOrderMarkToArchive ( EByteOrderMark ByteOrderMark)
private

◆ WriteRaw()

void FOutputDeviceFile::WriteRaw ( const TCHAR * C)
private

Member Data Documentation

◆ AppendIfExists

bool FOutputDeviceFile::AppendIfExists
private

Definition at line 187 of file OutputDeviceFile.h.

◆ AsyncWriter

FAsyncWriter* FOutputDeviceFile::AsyncWriter
private

Writes to a file on a separate thread

Definition at line 180 of file OutputDeviceFile.h.

◆ bDisableBackup

bool FOutputDeviceFile::bDisableBackup
private

If true, existing files will not be backed up

Definition at line 196 of file OutputDeviceFile.h.

◆ CategoryInclusionInternal

TUniquePtr<FCategoryInclusionInternal> FOutputDeviceFile::CategoryInclusionInternal
private

Definition at line 193 of file OutputDeviceFile.h.

◆ Dead

bool FOutputDeviceFile::Dead
private

Definition at line 188 of file OutputDeviceFile.h.

◆ Filename

TCHAR FOutputDeviceFile::Filename[1024]
private

Definition at line 186 of file OutputDeviceFile.h.

◆ OnFileOpenedFn

TFunction<void(const TCHAR*) FOutputDeviceFile::OnFileOpenedFn)
private

In bound, invoked when the log file is open successfully for writing, reporting the actual log filename.

Definition at line 184 of file OutputDeviceFile.h.

◆ WriterArchive

FArchive* FOutputDeviceFile::WriterArchive
private

Archive used by the async writer

Definition at line 182 of file OutputDeviceFile.h.


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