diff src/main.cpp @ 35:405e08552527 v2.4 v2.6

auto-detect on/off
author pyon@macmini
date Thu, 17 Nov 2011 21:03:30 +0900
parents c540dc3eabe5
children
line wrap: on
line diff
--- a/src/main.cpp	Sat Nov 12 13:18:03 2011 +0900
+++ b/src/main.cpp	Thu Nov 17 21:03:30 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : main.cpp
-// Last Change: 26-Oct-2011.
+// Last Change: 16-Nov-2011.
 //
 
 #include "common.h"
@@ -90,18 +90,25 @@
 void MyApp::InitLog()
 {
     wxDateTime now = wxDateTime::Now();
+    log_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("log");
+
+    if ( wxFileExists( log_file ) ) {
+        wxString log_bak = log_file + wxT(".bak");
+        wxRenameFile( log_file, log_bak, true );
+    }
+
     wxTextFile logfile;
-    logfile.Open(wxT("log"));
-    logfile.Clear();
+    logfile.Create( log_file );
     logfile.AddLine( now.Format(wxT("%Y-%m-%d %H:%M:%S ")) + wxT("[Application start...]") );
     logfile.Write();
     logfile.Close();
 }
+
 void MyApp::WriteLog( wxString msg )
 {
     wxDateTime now = wxDateTime::Now();
     wxTextFile logfile;
-    logfile.Open(wxT("log"));
+    logfile.Open( log_file );
     logfile.AddLine( now.Format(wxT("%Y-%m-%d %H:%M:%S ")) + msg );
     logfile.Write();
     logfile.Close();