Add new items to top.
(This summarizes all changes to all files under Src, including Src\Languages.)
+2007-03-13 Kimmo
+ PATCH: [ 1679196 ] Cleanup logfile class usage
+ Src: DiffWrapper.cpp DirActions.cpp DirDoc.cpp DirScan.cpp FolderCmp.cpp MainFrm.cpp
+ Merge.cpp Merge.h MergeDoc.cpp Plugins.cpp StdAfx.cpp StdAfx.h
+ Src/Common: LogFile.cpp LogFile.h
+
2007-03-12 Kimmo
Remove unneeded include lines
Src: DirDoc.cpp
* @brief Implementation file for CLogFile
*
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#include "stdafx.h"
#define new DEBUG_NEW
#endif
-/**
- * @brief Global name for mutes protecting log file access.
- */
+/** @brief Global name for mutes protecting log file access. */
static const TCHAR MutexName[] = _T("WINMERGE_LOG_MUTEX");
-/**
- * @brief Constant for Megabyte.
- */
+/** @brief Constant for Megabyte. */
static const int MEGA = 1024 * 1024;
/**
}
return str;
}
+
+/** @brief Report DeleteFile() failure to Log */
+UINT CLogFile::DeleteFileFailed(LPCTSTR path)
+{
+ return Write(CLogFile::LERROR|CLogFile::LOSERROR|CLogFile::LDEBUG, _T("DeleteFile(%s) failed: "), path);
+}
* @brief Declaration file for CLogFile
*
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#if !defined(AFX_LOGFILE_H__803A3641_FE03_11D0_95CD_444553540000__INCLUDED_)
UINT Write(UINT level, LPCTSTR pszFormat, ...);
UINT Write(UINT level, DWORD idFormatString, ...);
+ UINT DeleteFileFailed(LPCTSTR path);
+
void SetMaxLogSize(DWORD dwMax) { m_nMaxSize = dwMax; }
CString GetPath() const { return m_strLogPath; }
#endif
extern int recursive;
-extern CLogFile gLog;
static void FreeDiffUtilsScript(struct change * & script);
static void CopyTextStats(const file_data * inf, FileTextStats * myTextStats);
static char THIS_FILE[] = __FILE__;
#endif
-extern CLogFile gLog;
-
/**
* @brief Ask user a confirmation for copying item(s).
* Shows a confirmatino dialog for copy operation. Depending ont item count
static char THIS_FILE[] = __FILE__;
#endif
-extern CLogFile gLog;
-
/////////////////////////////////////////////////////////////////////////////
// CDirDoc
m_statusCursor = new CustomStatusCursor(0, IDC_APPSTARTING, LoadResString(IDS_STATUS_RESCANNING));
- gLog.Write(CLogFile::LNOTICE, _T("Starting directory scan:\n\tLeft: %s\n\tRight: %s\n"),
+ GetLog()->Write(CLogFile::LNOTICE, _T("Starting directory scan:\n\tLeft: %s\n\tRight: %s\n"),
m_pCtxt->GetLeftPath(), m_pCtxt->GetRightPath());
m_pCompareStats->Reset();
m_pDirView->StartCompare(m_pCompareStats);
*/
void CDirDoc::CompareReady()
{
- gLog.Write(CLogFile::LNOTICE, _T("Directory scan complete\n"));
+ GetLog()->Write(CLogFile::LNOTICE, _T("Directory scan complete\n"));
// finish the cursor (the hourglass/pointer combo) we had open during display
delete m_statusCursor;
*/
void CDirDoc::AbortCurrentScan()
{
- gLog.Write(CLogFile::LNOTICE, _T("Dircompare aborted!"));
+ GetLog()->Write(CLogFile::LNOTICE, _T("Dircompare aborted!"));
m_diffThread.Abort();
}
*
* @brief Implementation of DirScan (q.v.) and helper functions
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#include "stdafx.h"
#include <shlwapi.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include "Merge.h"
+#include "LogFile.h"
#include "DirScan.h"
#include "CompareStats.h"
#include "common/unicoder.h"
#include "DiffWrapper.h"
#include "FolderCmp.h"
#include "FileFilterHelper.h"
-#include "logfile.h"
#include "paths.h"
#include "FileTransform.h"
#include "codepage.h"
}
}
- gLog.Write
+ GetLog()->Write
(
CLogFile::LCOMPAREDATA, _T("name=<%s>, leftdir=<%s>, rightdir=<%s>, code=%d"),
(LPCTSTR)di.sLeftFilename, (LPCTSTR)_T("di.left.spath"), (LPCTSTR)_T("di.right.spath"), di.diffcode
di.diffcode = code;
- gLog.Write
+ GetLog()->Write
(
CLogFile::LCOMPAREDATA, _T("name=<%s>, leftdir=<%s>, rightdir=<%s>, code=%d"),
(LPCTSTR)di.sLeftFilename, (LPCTSTR)_T("di.left.spath"), (LPCTSTR)_T("di.right.spath"), code
\r
\r
#include "stdafx.h"\r
+#include "LogFile.h"\r
+#include "Merge.h"\r
#include "paths.h"\r
#include "FilterList.h"\r
#include "DiffContext.h"\r
m_diffFileData.Reset();\r
// delete the temp files after comparison\r
if (filepathTransformed1 != filepathUnpacked1)\r
- VERIFY(::DeleteFile(filepathTransformed1) || gLog::DeleteFileFailed(filepathTransformed1));\r
+ VERIFY(::DeleteFile(filepathTransformed1) || GetLog()->DeleteFileFailed(filepathTransformed1));\r
if (filepathTransformed2 != filepathUnpacked2)\r
- VERIFY(::DeleteFile(filepathTransformed2) || gLog::DeleteFileFailed(filepathTransformed2));\r
+ VERIFY(::DeleteFile(filepathTransformed2) || GetLog()->DeleteFileFailed(filepathTransformed2));\r
if (filepathUnpacked1 != filepath1)\r
- VERIFY(::DeleteFile(filepathUnpacked1) || gLog::DeleteFileFailed(filepathUnpacked1));\r
+ VERIFY(::DeleteFile(filepathUnpacked1) || GetLog()->DeleteFileFailed(filepathUnpacked1));\r
if (filepathUnpacked2 != filepath2)\r
- VERIFY(::DeleteFile(filepathUnpacked2) || gLog::DeleteFileFailed(filepathUnpacked2));\r
+ VERIFY(::DeleteFile(filepathUnpacked2) || GetLog()->DeleteFileFailed(filepathUnpacked2));\r
return code;\r
}\r
\r
*
* @brief Implementation of the CMainFrame class
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#include "stdafx.h"
#include "LocationView.h"
#include "SyntaxColors.h"
-#include "diff.h"
#include "coretools.h"
#include "Splash.h"
#include "PropLineFilter.h"
#include "paths.h"
#include "WaitStatusCursor.h"
#include "PatchTool.h"
-#include "FileTransform.h"
#include "Plugins.h"
#include "SelectUnpackerDlg.h"
#include "files.h"
static char THIS_FILE[] = __FILE__;
#endif
-extern CLogFile gLog;
-
static void LoadToolbarImageList(UINT nIDResource, CImageList& ImgList);
/////////////////////////////////////////////////////////////////////////////
// uncomment this when the GUI allows to toggle the mode
// g_bPredifferMode = theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL);
- // TODO: read preference for logging
-
- int logging = GetOptionsMgr()->GetInt(OPT_LOGGING);
- if (logging > 0)
- {
- gLog.EnableLogging(TRUE);
- gLog.SetFile(_T("WinMerge.log"));
-
- if (logging == 1)
- gLog.SetMaskLevel(CLogFile::LALL);
- else if (logging == 2)
- gLog.SetMaskLevel(CLogFile::LERROR | CLogFile::LWARNING);
- }
-
m_pSyntaxColors = new SyntaxColors();
if (m_pSyntaxColors)
m_pSyntaxColors->Initialize(GetOptionsMgr());
CMainFrame::~CMainFrame()
{
- gLog.EnableLogging(FALSE);
+ GetLog()->EnableLogging(FALSE);
// Delete all temporary folders belonging to this process
GetClearTempPath(NULL, NULL);
if (1)
{
- gLog.Write(_T("### Begin Comparison Parameters #############################\r\n")
+ GetLog()->Write(_T("### Begin Comparison Parameters #############################\r\n")
_T("\tLeft: %s\r\n")
_T("\tRight: %s\r\n")
_T("\tRecurse: %d\r\n")
break;
if (strLeft.Find(path) == 0)
{
- VERIFY(::DeleteFile(strLeft) || gLog::DeleteFileFailed(strLeft));
+ VERIFY(::DeleteFile(strLeft) || GetLog()->DeleteFileFailed(strLeft));
}
SysFreeString(Assign(strLeft, piHandler->GetDefaultName(m_hWnd, strLeft)));
strLeft.Insert(0, '\\');
break;;
if (strRight.Find(path) == 0)
{
- VERIFY(::DeleteFile(strRight) || gLog::DeleteFileFailed(strRight));
+ VERIFY(::DeleteFile(strRight) || GetLog()->DeleteFileFailed(strRight));
}
SysFreeString(Assign(strRight, piHandler->GetDefaultName(m_hWnd, strRight)));
strRight.Insert(0, '\\');
// Anything that can go wrong inside InitCompare() will yield an
// exception. There is no point in checking return value.
pDirDoc->InitCompare(paths, bRecurse, pTempPathContext);
- gLog.Write(CLogFile::LNOTICE, _T("Open dirs: Left: %s\n\tRight: %s."),
+ GetLog()->Write(CLogFile::LNOTICE, _T("Open dirs: Left: %s\n\tRight: %s."),
strLeft, strRight);
pDirDoc->SetReadOnly(TRUE, bROLeft);
}
else
{
- gLog.Write(CLogFile::LNOTICE, _T("Open files: Left: %s\n\tRight: %s."),
+ GetLog()->Write(CLogFile::LNOTICE, _T("Open files: Left: %s\n\tRight: %s."),
strLeft, strRight);
FileLocation filelocLeft(strLeft);
dsk_rc.bottom = dsk_rc.top + ::GetSystemMetrics(SM_CYVIRTUALSCREEN);
if (nCmdShow != SW_MINIMIZE && theApp.GetProfileInt(_T("Settings"), _T("MainMax"), FALSE))
{
- CMDIFrameWnd::ActivateFrame(SW_MAXIMIZE);
+ CMDIFrameWnd::ActivateFrame(SW_MAXIMIZE);
}
else if (rc.Width() != 0 && rc.Height() != 0)
{
files[1] = files[0];
}
- gLog.Write(CLogFile::LNOTICE, _T("D&D open: Left: %s\n\tRight: %s."),
+ GetLog()->Write(CLogFile::LNOTICE, _T("D&D open: Left: %s\n\tRight: %s."),
files[0], files[1]);
// Check if they dropped a project file
LoadConfigBoolSetting(&configLog.m_miscSettings.bAutomaticRescan, options, OPT_AUTOMATIC_RESCAN, cfgdir);
LoadConfigBoolSetting(&configLog.m_miscSettings.bAllowMixedEol, options, OPT_ALLOW_MIXED_EOL, cfgdir);
LoadConfigBoolSetting(&configLog.m_miscSettings.bScrollToFirst, options, OPT_SCROLL_TO_FIRST, cfgdir);
-// LoadConfigBoolSetting(&configLog.m_miscSettings.bBackup, options, OPT_CREATE_BACKUPS, cfgdir);
LoadConfigBoolSetting(&configLog.m_miscSettings.bViewWhitespace, options, OPT_VIEW_WHITESPACE, cfgdir);
LoadConfigBoolSetting(&configLog.m_miscSettings.bMovedBlocks, options, OPT_CMP_MOVED_BLOCKS, cfgdir);
LoadConfigBoolSetting(&configLog.m_miscSettings.bShowLinenumbers, options, OPT_VIEW_LINENUMBERS, cfgdir);
* @brief Defines the class behaviors for the application.
*
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#include "stdafx.h"
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
-extern CLogFile gLog;
-
static void AddEnglishResourceHook();
/**
LPCTSTR WinMergeOptionName;
};
+/**
+ * @brief Get Options Manager.
+ * @return Pointer to OptionsMgr.
+ */
COptionsMgr * GetOptionsMgr()
{
CMergeApp *pApp = static_cast<CMergeApp *>(AfxGetApp());
return pApp->GetMergeOptionsMgr();
}
+/**
+ * @brief Get Log.
+ * @return Pointer to Log.
+ */
+CLogFile * GetLog()
+{
+ CMergeApp *pApp = static_cast<CMergeApp *>(AfxGetApp());
+ return pApp->GetMergeLog();
+}
+
+
/////////////////////////////////////////////////////////////////////////////
// CMergeApp construction
, m_nLastCompareResult(0)
, m_bNonInteractive(false)
, m_pOptions(NULL)
+, m_pLog(NULL)
{
// add construction code here,
// Place all significant initialization in InitInstance
{
delete m_pOptions;
delete m_pLangDlg;
+ delete m_pLog;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMergeApp object
m_pOptions = new CRegOptionsMgr;
OptionsInit(); // Implementation in OptionsInit.cpp
+ m_pLog = new CLogFile();
+
+ int logging = GetOptionsMgr()->GetInt(OPT_LOGGING);
+ if (logging > 0)
+ {
+ m_pLog->EnableLogging(TRUE);
+ m_pLog->SetFile(_T("WinMerge.log"));
+
+ if (logging == 1)
+ m_pLog->SetMaskLevel(CLogFile::LALL);
+ else if (logging == 2)
+ m_pLog->SetMaskLevel(CLogFile::LERROR | CLogFile::LWARNING);
+ }
+
// Parse command-line arguments.
MergeCmdLineInfo cmdInfo(*__targv);
ParseCommandLine(cmdInfo);
// Initialize i18n (multiple language) support
- m_pLangDlg->SetLogFile(&gLog);
+ m_pLangDlg->SetLogFile(GetLog());
m_pLangDlg->InitializeLanguage();
AddEnglishResourceHook(); // Use English string when l10n (foreign) string missing
* @brief main header file for the MERGE application
*
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#if !defined(AFX_MERGE_H__BBCD4F88_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)
class CMainFrame;
class CLanguageSelect;
class MergeCmdLineInfo;
+class CLogFile;
/////////////////////////////////////////////////////////////////////////////
// CMergeApp:
void OptionsInit();
void ResetOptions() { OptionsInit(); }
+ CLogFile * GetMergeLog() { return m_pLog; }
+
// Implementation
protected:
private:
CRegOptionsMgr *m_pOptions;
CAssureScriptsForThread * m_mainThreadScripts;
+ CLogFile * m_pLog;
int m_nLastCompareResult;
bool m_bNonInteractive;
};
extern CMergeApp theApp;
COptionsMgr * GetOptionsMgr();
+CLogFile * GetLog();
/////////////////////////////////////////////////////////////////////////////
CMergeDoc *GetDoc();
static char THIS_FILE[] = __FILE__;
#endif
-extern CLogFile gLog;
-
/** @brief Max len of path in caption. */
static const UINT CAPTION_PATH_MAX = 50;
*
* @brief Support for VBS Scriptlets, VB ActiveX DLL, VC++ COM DLL
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#include "StdAfx.h"
#endif
#include "pcre.h"
+#include "LogFile.h"
+#include "Merge.h"
#include "Ucs2Utf8.h"
#include "FileTransform.h"
#include "FileFilterMgr.h"
#include "Exceptions.h"
#include "RegKey.h"
#include "paths.h"
-#include "logfile.h"
-extern CLogFile gLog;
#ifdef _DEBUG
#define new DEBUG_NEW
if (IsWindowsScriptThere())
GetScriptletsAt(path, _T(".sct"), theScriptletList ); // VBS/JVS scriptlet
else
- gLog.Write(CLogFile::LWARNING, _T("\n .sct plugins disabled (Windows Script Host not found)"));
+ GetLog()->Write(CLogFile::LWARNING, _T("\n .sct plugins disabled (Windows Script Host not found)"));
GetScriptletsAt(path, _T(".ocx"), theScriptletList ); // VB COM object
GetScriptletsAt(path, _T(".dll"), theScriptletList ); // VC++ COM object
scriptletsLoaded = true;
#include "stdafx.h"
#include "LogFile.h"
-
-// Logging
-CLogFile gLog;
-
-/** @brief Report DeleteFile() failure to gLog */
-UINT gLog::DeleteFileFailed(LPCTSTR path)
-{
- return::gLog.Write(CLogFile::LERROR|CLogFile::LOSERROR|CLogFile::LDEBUG, _T("DeleteFile(%s) failed: "), path);
-}
+#include "Merge.h"
// Convert any negative inputs to negative char equivalents
// This is aimed at correcting any chars mistakenly
TRACE(_T("%s: %s\n"), (LPCTSTR)now, sz);
#if defined (_DEBUG) || defined (ENABLE_LOG)
- gLog.Write(CLogFile::LERROR, sz);
+ GetLog()->Write(CLogFile::LERROR, sz);
#endif
}
/** @brief Get appropriate clipboard format for TCHAR text, ie, CF_TEXT or CF_UNICODETEXT */
int GetClipTcharTextFormat();
-class CLogFile;
-extern CLogFile gLog;
-
- /** @brief Shortcuts for common gLog messages */
-struct gLog
-{
- static UINT DeleteFileFailed(LPCTSTR path);
-};
-
bool IsUnicodeBuild();
/** @brief include for the custom dialog boxes, with do not ask/display again */