shuusei24112:server.logをserver-yyyymmdd.logの形式で記録(idea by MataPara)

diff --dos -urN 24111/mainform.pas 24112/mainform.pas
--- 24111/mainform.pas	Tue Jan 28 13:06:00 2003
+++ 24112/mainform.pas	Tue Jan 28 22:46:46 2003
@@ -677,18 +677,24 @@
 var
  i: Integer;
  r: TRect;
+ logfilename: String;
 begin
+ ShortDateFormat := 'yyyymmdd';
+ logfilename:=ApplicationDir+'server-'+DateToStr(now)+'.log';
+ ShortDateFormat := 'yyyy/mm/dd';
+ if not FileExists(logfilename) then
+   try
+    log_file:=TFileStream.Create(logfilename,fmCreate);
+    log_file.Free;
+    except
+   end;
  try
-  log_file:=TFileStream.Create(ApplicationDir+'server.log',fmCreate);
-  log_file.Free;
-  except
- end;
- try
-   log_file:=TFileStream.Create(ApplicationDir+'server.log',fmOpenWrite or fmShareDenyWrite);
+   log_file:=TFileStream.Create(logfilename,fmOpenWrite or fmShareDenyWrite);
+   log_file.Seek(0,soFromEnd);
   except
    log_file:=nil;
-   LogStartup('mainform::create: cannot open "server.log" !!!');
-   DebugLog('Error: cannot open file "server.log"');
+   LogStartup('mainform::create: cannot open "'+logfilename+'" !!!');
+   DebugLog('Error: cannot open file '+logfilename);
  end;
  // init variables
  LogStartup('mainform::create: creating main window');
diff --dos -urN 24111/stypes.pas 24112/stypes.pas
--- 24111/stypes.pas	Tue Jan 28 13:15:48 2003
+++ 24112/stypes.pas	Tue Jan 28 22:48:34 2003
@@ -1561,6 +1561,8 @@
 end;
 
 procedure Log(id: Integer; cmd: String; file_only: Boolean=false);
+var
+ logfilename: String;
 begin
  if running or file_only then
  try
@@ -1571,6 +1573,24 @@
    if log_file=nil then exit;
    if not log_to_file then exit;
    cmd:=cmd+#13#10;
+   ShortDateFormat := 'yyyymmdd';
+   logfilename:=ApplicationDir+'server-'+DateToStr(now)+'.log';
+   ShortDateFormat := 'yyyy/mm/dd';
+   if not FileExists(logfilename) then begin
+    try
+     log_file.Free;
+     log_file:=TFileStream.Create(logfilename,fmCreate);
+     log_file.Free;
+     except
+    end;
+    log_file:=nil;
+    try
+     log_file:=TFileStream.Create(logfilename,fmOpenWrite or fmShareDenyWrite);
+     except
+      log_file:=nil;
+      DebugLog('Error: cannot open file '+logfilename);
+    end;
+   end;
    log_file.Write(cmd[1],Length(cmd));
   except
  end;
@@ -1591,7 +1611,7 @@
 
 procedure LogConsole(id: Integer; cmd: String);
 var
- str: String;
+ str,logfilename: String;
 begin
  if not running then exit;
  try
@@ -1599,8 +1619,27 @@
    sync_reply_list.AddDoubleCmd(MSG_SR_CONSOLELOG,id,'',str);
    if log_file=nil then exit;
    cmd:=GetLogTime+'Console: '+cmd+#13#10;
-   if log_to_file then
+   if log_to_file then begin
+    ShortDateFormat := 'yyyymmdd';
+    logfilename:=ApplicationDir+'server-'+DateToStr(now)+'.log';
+    ShortDateFormat := 'yyyy/mm/dd';
+    if not FileExists(logfilename) then begin
+     try
+      log_file.Free;
+      log_file:=TFileStream.Create(logfilename,fmCreate);
+      log_file.Free;
+      except
+     end;
+     log_file:=nil;
+     try
+      log_file:=TFileStream.Create(logfilename,fmOpenWrite or fmShareDenyWrite);
+      except
+       log_file:=nil;
+       DebugLog('Error: cannot open file '+logfilename);
+     end;
+    end;
     log_file.Write(cmd[1],Length(cmd));
+   end;
   except
  end;  
 end;
diff --dos -urN 24111/thread.pas 24112/thread.pas
--- 24111/thread.pas	Thu Jan 23 17:12:22 2003
+++ 24112/thread.pas	Tue Jan 28 22:51:02 2003
@@ -589,6 +589,7 @@
 procedure TMainThread.ProcessCmd(dcmd: TNapDoubleCmd);
 var
  ch: TChannel;
+ logfilename: String;
 begin
  tmp_pos:=1492;
  case dcmd.id1 of
@@ -617,6 +618,9 @@
                      end;
    MSG_CMD_RESETLOG: begin
                        tmp_pos:=1499;
+                       ShortDateFormat := 'yyyymmdd';
+                       logfilename:=ApplicationDir+'server-'+DateToStr(now)+'.log';
+                       ShortDateFormat := 'yyyy/mm/dd';
                        try
                          if log_file<>nil then
                           log_file.Free;
@@ -624,7 +628,7 @@
                         except
                        end;
                        try
-                        log_file:=TFileStream.Create(ApplicationDir+'server.log',fmCreate);
+                        log_file:=TFileStream.Create(logfilename,fmCreate);
                         log_file.Free;
                         except
                        end;
@@ -632,10 +636,10 @@
                        tmp_pos:=1500;
                        try
                         if log_to_file then
-                         log_file:=TFileStream.Create(ApplicationDir+'server.log',fmOpenWrite or fmShareDenyWrite);
+                         log_file:=TFileStream.Create(logfilename,fmOpenWrite or fmShareDenyWrite);
                         except
                          log_file:=nil;
-                         DebugLog('Error: cannot reset file "server.log"');
+                         DebugLog('Error: cannot reset file '+logfilename);
                        end;
                        // resetting debug file
                        try