Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2011-05-18 00:56:50 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2011-05-18 01:08:40 +0400
commitd72cf8c4d99a9e18bae01ec0858e262b3f4f3e9f (patch)
tree570859b8a29ab6b9faeca4453dddd0b2facd6182 /common
parent02370d11aac078cc0c63917a2412c4629e573ca1 (diff)
Implement debug logging into a file.
Diffstat (limited to 'common')
-rw-r--r--common/DSUtilLite/DShowUtil.cpp36
-rw-r--r--common/DSUtilLite/DShowUtil.h5
-rw-r--r--common/baseclasses/wxdebug.cpp3
3 files changed, 42 insertions, 2 deletions
diff --git a/common/DSUtilLite/DShowUtil.cpp b/common/DSUtilLite/DShowUtil.cpp
index 9e911c6d..546b3d30 100644
--- a/common/DSUtilLite/DShowUtil.cpp
+++ b/common/DSUtilLite/DShowUtil.cpp
@@ -49,6 +49,42 @@ void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
}
}
+#ifdef DEBUG
+
+#include <Shlobj.h>
+#include <Shlwapi.h>
+
+extern HANDLE m_hOutput;
+extern HRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName);
+void DbgSetLogFile(LPCTSTR szFile)
+{
+ if (m_hOutput != INVALID_HANDLE_VALUE) {
+ CloseHandle (m_hOutput);
+ m_hOutput = INVALID_HANDLE_VALUE;
+ }
+
+ m_hOutput = CreateFile(szFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (INVALID_HANDLE_VALUE == m_hOutput &&
+ GetLastError() == ERROR_SHARING_VIOLATION)
+ {
+ TCHAR uniqueName[MAX_PATH] = {0};
+ if (SUCCEEDED(DbgUniqueProcessName(szFile, uniqueName)))
+ {
+ m_hOutput = CreateFile(uniqueName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ }
+ }
+}
+
+void DbgSetLogFileDesktop(LPCTSTR szFile)
+{
+ TCHAR szLogPath[512];
+ SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, szLogPath);
+ PathAppend(szLogPath, szFile);
+ DbgSetLogFile(szLogPath);
+}
+#endif
+
void split(std::string& text, std::string& separators, std::list<std::string>& words)
{
size_t n = text.length();
diff --git a/common/DSUtilLite/DShowUtil.h b/common/DSUtilLite/DShowUtil.h
index 07393e7c..c6dc5b63 100644
--- a/common/DSUtilLite/DShowUtil.h
+++ b/common/DSUtilLite/DShowUtil.h
@@ -40,10 +40,15 @@ template <class T> void SafeRelease(T **ppT)
#ifdef _DEBUG
#define DBG_TIMING(x,l,y) DWORD start = timeGetTime(); y; DWORD end = timeGetTime(); if(end-start>l) DbgLog((LOG_TRACE, 10, L"TIMING: %S took %u ms", x, end-start));
+extern void DbgSetLogFile(LPCTSTR szLogFile);
+extern void DbgSetLogFileDesktop(LPCTSTR szLogFile);
#else
#define DBG_TIMING(x,l,y) y;
+#define DbgSetLogFile(sz)
+#define DbgSetLogFileDesktop(sz)
#endif
+
// SAFE_ARRAY_DELETE macro.
// Deletes an array allocated with new [].
diff --git a/common/baseclasses/wxdebug.cpp b/common/baseclasses/wxdebug.cpp
index 0e703133..2ef34bd6 100644
--- a/common/baseclasses/wxdebug.cpp
+++ b/common/baseclasses/wxdebug.cpp
@@ -214,9 +214,8 @@ void WINAPI DbgOutString(LPCTSTR psz)
#else
WriteFile (m_hOutput, psz, cb, &dw, NULL);
#endif
- } else {
- OutputDebugString (psz);
}
+ OutputDebugString (psz);
}