浏览代码

Refactoring

Source commit: 3f6916fcdc8bf21ff1e0c3c7e77049de0d509841
Martin Prikryl 1 月之前
父节点
当前提交
c39d2b750f
共有 4 个文件被更改,包括 8 次插入7 次删除
  1. 1 2
      source/core/Common.cpp
  2. 1 2
      source/core/CoreMain.h
  3. 5 2
      source/core/SessionInfo.cpp
  4. 1 1
      source/windows/Setup.cpp

+ 1 - 2
source/core/Common.cpp

@@ -4522,8 +4522,7 @@ UnicodeString GetAncestorProcessNames()
 //---------------------------------------------------------------------------
 void LogModules()
 {
-  bool DoLogModules = ApplicationLog->Logging;
-  if (DoLogModules)
+  if (ApplicationLog->Logging)
   {
     const int Max = 1024;
     HMODULE Modules[Max];

+ 1 - 2
source/core/CoreMain.h

@@ -9,8 +9,7 @@ extern TConfiguration *Configuration;
 extern TStoredSessionList *StoredSessions;
 extern bool AnySession;
 extern TApplicationLog * ApplicationLog;
-#define APPLOG_INTERNAL(S) if (ApplicationLog->Logging) ApplicationLog->Log(S)
-#define AppLog(S) APPLOG_INTERNAL(S)
+#define AppLog(S) if (ApplicationLog->Logging) ApplicationLog->Log(S)
 #define AppLogFmt(S, F) AppLog(FORMAT(S, F))
 //---------------------------------------------------------------------------
 void CoreInitialize();

+ 5 - 2
source/core/SessionInfo.cpp

@@ -1802,7 +1802,7 @@ void TApplicationLog::AddStartupInfo()
 //---------------------------------------------------------------------------
 void __fastcall TApplicationLog::Log(const UnicodeString & S)
 {
-  if (FFile != NULL)
+  if (Logging)
   {
     TDateTime N = Now();
     UnicodeString Timestamp = FormatDateTime(L"yyyy-mm-dd hh:nn:ss.zzz", N);
@@ -1814,7 +1814,10 @@ void __fastcall TApplicationLog::Log(const UnicodeString & S)
 
     {
       TGuard Guard(FCriticalSection.get());
-      fwrite(UtfLine.c_str(), 1, Writting, static_cast<FILE *>(FFile));
+      if (FFile != NULL)
+      {
+        fwrite(UtfLine.c_str(), 1, Writting, static_cast<FILE *>(FFile));
+      }
 
       __int64 SecondsSinceLastMemoryCheck = SecondsBetween(N, FLastMemoryCheck);
       CheckMemory = (SecondsSinceLastMemoryCheck >= 10);

+ 1 - 1
source/windows/Setup.cpp

@@ -1463,7 +1463,7 @@ void __fastcall TUpdateDownloadThread::UpdateDownloaded()
   {
     Params += L" /OpenGettingStarted";
   }
-  if (ApplicationLog->Logging)
+  if (!ApplicationLog->Path.IsEmpty())
   {
     Params += FORMAT(" /LOG=\"%s\"", (ApplicationLog->Path + L".setup"));
   }