From b93421c5021d54876d73305cd042c90e624d06a4 Mon Sep 17 00:00:00 2001
From: zilmar <zilmar@pj64-emu.com>
Date: Tue, 19 Apr 2016 20:37:41 +1000
Subject: [PATCH] [Common] Clean up log class

---
 Source/Common/LogClass.h          | 40 +++++++++++++++++--------------
 Source/Common/Trace.cpp           |  4 ++--
 Source/Common/Trace.h             |  2 +-
 Source/Glide64/Config.cpp         |  1 +
 Source/Glide64/trace.cpp          |  2 +-
 Source/Project64-core/AppInit.cpp |  2 +-
 6 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/Source/Common/LogClass.h b/Source/Common/LogClass.h
index cc9ed498c..93534f6f2 100644
--- a/Source/Common/LogClass.h
+++ b/Source/Common/LogClass.h
@@ -1,25 +1,18 @@
 #pragma once
+#include <string>
 #include "FileClass.h"
-#include "StdString.h"
-
-enum LOG_OPEN_MODE
-{
-    Log_New, Log_Append
-};
 
 class CLog
 {
+public:
+    enum LOG_OPEN_MODE
+    {
+        Log_New, Log_Append
+    };
+
     enum { MB = 1024 * 1024 };
     enum { MAX_FILE_SIZE = 10 * MB };
-
-    CFile  m_hLogFile;
-    bool   m_FlushOnWrite;
-    stdstr m_FileName;
-    bool   m_TruncateFileLog;
-    uint32_t  m_MaxFileSize;
-    uint32_t  m_FileChangeSize;
-
-public:
+    
     CLog(void);
     ~CLog(void);
 
@@ -36,8 +29,19 @@ public:
         m_FileChangeSize = (uint32_t)(Size * 0.1);
     }
     inline void SetTruncateFile(bool Truncate) { m_TruncateFileLog = Truncate; }
-    inline void SetFlush(bool Always)   { m_FlushOnWrite = Always; }
+    inline void SetFlush(bool Always) { m_FlushOnWrite = Always; }
     inline bool IsOpen(void) const { return m_hLogFile.IsOpen(); }
-    inline bool Flush(void)       { return m_hLogFile.Flush(); }
-    inline const stdstr & FileName(void) const { return m_FileName; }
+    inline bool Flush(void) { return m_hLogFile.Flush(); }
+    inline const std::string & FileName(void) const { return m_FileName; }
+
+private:
+    CLog(const CLog&);             // Disable copy constructor
+    CLog& operator=(const CLog&);  // Disable assignment
+    
+    CFile m_hLogFile;
+    bool m_FlushOnWrite;
+    std::string m_FileName;
+    bool m_TruncateFileLog;
+    uint32_t m_MaxFileSize;
+    uint32_t m_FileChangeSize;
 };
diff --git a/Source/Common/Trace.cpp b/Source/Common/Trace.cpp
index 0a2fae343..2012e8c67 100644
--- a/Source/Common/Trace.cpp
+++ b/Source/Common/Trace.cpp
@@ -171,8 +171,8 @@ const char * TraceModule(uint32_t module)
     return Unknown.c_str();
 }
 
-CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
-m_FlushFile(FlushFile)
+CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
+    m_FlushFile(FlushFile)
 {
     enum { MB = 1024 * 1024 };
 
diff --git a/Source/Common/Trace.h b/Source/Common/Trace.h
index d0932d907..de25d4d7a 100644
--- a/Source/Common/Trace.h
+++ b/Source/Common/Trace.h
@@ -25,7 +25,7 @@ __interface CTraceModule
 class CTraceFileLog : public CTraceModule
 {
 public:
-    CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
+    CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
     virtual ~CTraceFileLog();
 
     void SetFlushFile(bool bFlushFile);
diff --git a/Source/Glide64/Config.cpp b/Source/Glide64/Config.cpp
index ab7b20954..8386bb8c1 100644
--- a/Source/Glide64/Config.cpp
+++ b/Source/Glide64/Config.cpp
@@ -48,6 +48,7 @@
 #include "DepthBufferRender.h"
 #include "Config.h"
 #include "trace.h"
+#include <Common/StdString.h>
 
 short Set_basic_mode = 0, Set_texture_dir = 0, Set_log_dir = 0, Set_log_flush = 0;
 
diff --git a/Source/Glide64/trace.cpp b/Source/Glide64/trace.cpp
index 3067e313c..3c1451c1a 100644
--- a/Source/Glide64/trace.cpp
+++ b/Source/Glide64/trace.cpp
@@ -84,6 +84,6 @@ void SetupTrace(void)
         LogFilePath.DirectoryCreate();
     }
     LogFilePath.SetNameExtension("Glide64.log");
-    g_LogFile = new CTraceFileLog(LogFilePath, GetSystemSetting(Set_log_flush) != 0, Log_New, 500);
+    g_LogFile = new CTraceFileLog(LogFilePath, GetSystemSetting(Set_log_flush) != 0, CLog::Log_New, 500);
     TraceAddModule(g_LogFile);
 }
\ No newline at end of file
diff --git a/Source/Project64-core/AppInit.cpp b/Source/Project64-core/AppInit.cpp
index 41f98f3f7..7ee43a7c2 100644
--- a/Source/Project64-core/AppInit.cpp
+++ b/Source/Project64-core/AppInit.cpp
@@ -44,7 +44,7 @@ void AddLogModule(void)
     }
     LogFilePath.SetNameExtension("Project64.log");
 
-    g_LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New, 500);
+    g_LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, CLog::Log_New, 500);
     TraceAddModule(g_LogFile);
 }