Some bugfixing for logfile saving after testing in win32

This commit is contained in:
Mark Vejvoda
2010-03-23 07:59:24 +00:00
parent ae10ab55b2
commit 1fbff088e4
4 changed files with 30 additions and 9 deletions

View File

@@ -13,6 +13,7 @@
#define _SHARED_UTIL_UTIL_H_
#include <string>
#include <fstream>
using std::string;
@@ -20,6 +21,9 @@ namespace Shared{ namespace Util{
class SystemFlags
{
protected:
static std::ofstream fileStream;
public:
enum DebugType {
@@ -32,6 +36,7 @@ public:
static const char *debugLogFile;
static void OutputDebug(DebugType type, const char *fmt, ...);
static void Close();
};
const string sharedLibVersionString= "v0.4.1";

View File

@@ -17,7 +17,6 @@
#include <cstring>
#include <cstdio>
#include <stdarg.h>
#include <fstream>
#include "leak_dumper.h"
@@ -25,10 +24,16 @@ using namespace std;
namespace Shared{ namespace Util{
bool SystemFlags::enableDebugText = false;
bool SystemFlags::enableNetworkDebugInfo = false;
const char * SystemFlags::debugLogFile = NULL;
ofstream SystemFlags::fileStream;
void SystemFlags::Close() {
if(fileStream.is_open() == true) {
SystemFlags::fileStream.close();
}
}
void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
if((type == debugSystem && SystemFlags::enableDebugText == false) ||
@@ -41,7 +46,6 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
// Either output to a logfile or
if(SystemFlags::debugLogFile != NULL && SystemFlags::debugLogFile[0] != 0) {
static ofstream fileStream;
if(fileStream.is_open() == false) {
printf("Opening logfile [%s]\n",SystemFlags::debugLogFile);
fileStream.open(SystemFlags::debugLogFile, ios_base::out | ios_base::trunc);