My Project
Public Member Functions | Static Public Member Functions | List of all members
ParaEngine::CFileLogger Class Reference

It is a singleton class that is tightly integrated to the game engine. More...

#include <FileLogger.h>

Public Member Functions

bool LoadLogFromFile (const char *filename)
 Add new entries from file. More...
 
bool SaveLogToFile (const char *filename)
 save all logs to file.
 
bool BeginFileLog ()
 it will hook the CParaFile interface and record each read file operation. More...
 
void EndFileLog ()
 it will unhook the CParaFile interface and stop recording each read file operation. More...
 
void AddFile (const char *filename, bool bReadOnly=true)
 add a new file entry. More...
 
void MirrorFiles (const char *dirName, bool bOverwrite=false)
 copy all files to the given directory preserving relative path info. More...
 
void UpdateMirrorFiles (const char *dirName, bool bOverwrite=true)
 this function is equivalent to calling the following functions. More...
 
void AddExcludeFilter (const char *sPattern)
 exclude certain file extension, writable files, etc. More...
 
void Reset ()
 clear this instance for reuse. More...
 
bool IsBegin ()
 whether we are inside a log session. More...
 
bool HasFile (const string &filename)
 whether there is already a file with the given file name in the current file entry
 

Static Public Member Functions

static CFileLoggerGetInstance ()
 get the singleton instance. More...
 

Detailed Description

It is a singleton class that is tightly integrated to the game engine.

The default behavior of CFileLogger is this. Once activated, it first checks for ./InstallFiles.txt, and load it if it exists; then it checks for log file at temp/filelog.txt and load it if it exists. Then it hooks the CParaFile interface and record each read file operation. Once deactivated, it wrote the file log to temp/filelog.txt. Usually, at debug build, we will activate the File logger when application starts, and deactivate it when application exits. Basically file logger is an ideal way to check for read-only files, which can be zipped into a package at product release time.

See also
#define FILE_LOGGER_HOOK in CFileManager.cpp

Member Function Documentation

§ AddExcludeFilter()

void ParaEngine::CFileLogger::AddExcludeFilter ( const char *  sPattern)

exclude certain file extension, writable files, etc.

Parameters
sPattern

§ AddFile()

void ParaEngine::CFileLogger::AddFile ( const char *  filename,
bool  bReadOnly = true 
)

add a new file entry.

Parameters
filename
bReadOnlywhether this is a read-only file.

§ BeginFileLog()

bool ParaEngine::CFileLogger::BeginFileLog ( )

it will hook the CParaFile interface and record each read file operation.

§ EndFileLog()

void ParaEngine::CFileLogger::EndFileLog ( )

it will unhook the CParaFile interface and stop recording each read file operation.

§ GetInstance()

static CFileLogger* ParaEngine::CFileLogger::GetInstance ( )
static

get the singleton instance.

§ IsBegin()

bool ParaEngine::CFileLogger::IsBegin ( )

whether we are inside a log session.

§ LoadLogFromFile()

bool ParaEngine::CFileLogger::LoadLogFromFile ( const char *  filename)

Add new entries from file.

One can load multiple files, so that can append new identical files to previously recorded sessions

The logger file is just a list of file relative paths printed on each separate line.

File Logger File format

– any comments goes here
filename
filename
filename

Parameters
filename
Returns

§ MirrorFiles()

void ParaEngine::CFileLogger::MirrorFiles ( const char *  dirName,
bool  bOverwrite = false 
)

copy all files to the given directory preserving relative path info.

If file is not a disk file, zip file is searched.

Parameters
dirNamesuch as "_InstallFiles/"
bOverwriteif this is true, existing files will be overridden.

§ Reset()

void ParaEngine::CFileLogger::Reset ( )

clear this instance for reuse.

It will remove all file entries.

§ UpdateMirrorFiles()

void ParaEngine::CFileLogger::UpdateMirrorFiles ( const char *  dirName,
bool  bOverwrite = true 
)

this function is equivalent to calling the following functions.

LoadLogFromFile("InstallFiles.txt"); LoadLogFromFile("temp/filelog.txt"); MirrorFiles(dirName, bOverwrite);

Parameters
dirNamesuch as "_InstallFiles/"
bOverwriteif this is true, existing files will be overridden.

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