Changed the logging system to be more flexible and to support world synch logging

This commit is contained in:
Mark Vejvoda
2010-04-27 03:36:36 +00:00
parent 024f86ce7c
commit 6d4838f470
10 changed files with 215 additions and 47 deletions

View File

@@ -14,6 +14,7 @@
#include <string>
#include <fstream>
#include <map>
using std::string;
@@ -21,28 +22,60 @@ namespace Shared{ namespace Util{
class SystemFlags
{
public:
enum DebugType {
debugSystem,
debugNetwork,
debugPerformance,
debugWorldSynch
};
class SystemFlagsType
{
protected:
DebugType debugType;
public:
SystemFlagsType() {
this->debugType = debugSystem;
this->enabled = false;
this->fileStream = NULL;
this->debugLogFileName = "";
}
SystemFlagsType(DebugType debugType) {
this->debugType = debugType;
this->enabled = false;
this->fileStream = NULL;
this->debugLogFileName = "";
}
SystemFlagsType(DebugType debugType,bool enabled,
std::ofstream *fileStream,std::string debugLogFileName) {
this->debugType = debugType;
this->enabled = enabled;
this->fileStream = fileStream;
this->debugLogFileName = debugLogFileName;
}
bool enabled;
std::ofstream *fileStream;
std::string debugLogFileName;
};
protected:
static int lockFile;
static string lockfilename;
static std::ofstream fileStream;
static std::map<DebugType,SystemFlagsType> debugLogFileList;
public:
SystemFlags();
~SystemFlags();
enum DebugType {
debugSystem,
debugNetwork,
debugPerformance
};
static bool enableDebugText;
static bool enableNetworkDebugInfo;
static bool enablePerformanceDebugInfo;
static const char *debugLogFile;
static void init();
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
static void OutputDebug(DebugType type, const char *fmt, ...);
static void Close();
};