Browse Source

Quick.Log: Minor fixes

Unknown 7 years ago
parent
commit
741acddf3d
2 changed files with 19 additions and 18 deletions
  1. 0 2
      Quick.Console.pas
  2. 19 16
      Quick.Log.pas

+ 0 - 2
Quick.Console.pas

@@ -232,8 +232,6 @@ begin
 end;
 end;
 
 
 procedure coutBL(const s : string; cEventType : TEventType);
 procedure coutBL(const s : string; cEventType : TEventType);
-var
-  NewCoord : TCoord;
 begin
 begin
   coutXY(0,GetCurSorMaxBottom - 1,s,cEventType);
   coutXY(0,GetCurSorMaxBottom - 1,s,cEventType);
 end;
 end;

+ 19 - 16
Quick.Log.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.17
   Version     : 1.17
   Created     : 10/04/2016
   Created     : 10/04/2016
-  Modified    : 17/09/2017
+  Modified    : 24/10/2017
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -43,7 +43,6 @@ type
   TMemoryLog = class
   TMemoryLog = class
   private
   private
     fLines : TStrings;
     fLines : TStrings;
-    fText : string;
     fEnabled : Boolean;
     fEnabled : Boolean;
     function GetLogText : string;
     function GetLogText : string;
   public
   public
@@ -159,7 +158,7 @@ begin
   begin
   begin
     try
     try
       fCurrentLogSize := TFile.GetSize(logname);
       fCurrentLogSize := TFile.GetSize(logname);
-      if fCurrentLogSize > fLimitLogSize Then if DeleteFile(logname) then fCurrentLogSize := 0;
+      if fCurrentLogSize > fLimitLogSize then if DeleteFile(logname) then fCurrentLogSize := 0;
     except
     except
       raise Exception.Create('can''t access to log file!');
       raise Exception.Create('can''t access to log file!');
     end;
     end;
@@ -170,19 +169,23 @@ begin
   //writes header info
   //writes header info
   if fShowHeaderInfo then
   if fShowHeaderInfo then
   begin
   begin
-    Self.WriteLog(FillStr('-',70));
-    Self.WriteLog(Format('Application : %s %s',[ExtractFilenameWithoutExt(ParamStr(0)),GetAppVersionFullStr]));
-    Self.WriteLog(Format('Path        : %s',[ExtractFilePath(ParamStr(0))]));
-    Self.WriteLog(Format('CPU cores   : %d',[CPUCount]));
-    Self.WriteLog(Format('OS version  : %s',[TOSVersion.ToString]));
-    Self.WriteLog(Format('Host        : %s',[GetComputerName]));
-    Self.WriteLog(Format('Username    : %s',[Trim(GetLoggedUserName)]));
-    Self.WriteLog(Format('Started     : %s',[NowStr]));
-    if IsService then Self.WriteLog('AppType     : Service')
-      else if System.IsConsole then Self.WriteLog('AppType     : Console');
-
-    if IsDebug then Self.WriteLog('Debug mode  : On');
-    Self.WriteLog(FillStr('-',70));
+    try
+      Self.WriteLog(FillStr('-',70));
+      Self.WriteLog(Format('Application : %s %s',[ExtractFilenameWithoutExt(ParamStr(0)),GetAppVersionFullStr]));
+      Self.WriteLog(Format('Path        : %s',[ExtractFilePath(ParamStr(0))]));
+      Self.WriteLog(Format('CPU cores   : %d',[CPUCount]));
+      Self.WriteLog(Format('OS version  : %s',[TOSVersion.ToString]));
+      Self.WriteLog(Format('Host        : %s',[GetComputerName]));
+      Self.WriteLog(Format('Username    : %s',[Trim(GetLoggedUserName)]));
+      Self.WriteLog(Format('Started     : %s',[NowStr]));
+      if IsService then Self.WriteLog('AppType     : Service')
+        else if System.IsConsole then Self.WriteLog('AppType     : Console');
+
+      if IsDebug then Self.WriteLog('Debug mode  : On');
+      Self.WriteLog(FillStr('-',70));
+    except
+      on E : Exception do Self.WriteLog('Can''t get info: ' + e.message);
+    end;
   end;
   end;
   Result := True;
   Result := True;
 end;
 end;