summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-17 12:29:56 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-18 00:51:05 +0100
commit66b170230d41a9b35a86962b953d898d78a9a324 (patch)
treeaab0000593486473704ed4af7aef4df40c2a6735 /vcl/win
parent3852d46941107c0ad596cfc0fe9098433292994c (diff)
windows: Improve logging.
Change-Id: I15e6d240b3c94af07e9b39cc16efb581869729f2
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/source/window/salframe.cxx73
1 files changed, 18 insertions, 55 deletions
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index d42b0f540a4d..d2fef8fc0903 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -5974,64 +5974,27 @@ bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LR
return bResult;
}
-bool ImplWriteLastError( DWORD lastError, const char *szApiCall )
+void ImplWriteLastError(DWORD lastError, const char *szApiCall)
{
- static int first=1;
- // if VCL_LOGFILE_ENABLED is set, Win32 API error messages can be written
- // to %TMP%/vcl.log or %TEMP%/vcl.log
- static char *logEnabled = getenv("VCL_LOGFILE_ENABLED");
- if( logEnabled )
- {
- bool bSuccess = FALSE;
- static char *szTmp = getenv("TMP");
- if( !szTmp || !*szTmp )
- szTmp = getenv("TEMP");
- if( szTmp && *szTmp )
- {
- char fname[5000];
- strcpy( fname, szTmp );
- if( fname[strlen(fname) - 1] != '\\' )
- strcat( fname, "\\");
- strcat( fname, "vcl.log" );
- FILE *fp = fopen( fname, "a" ); // always append
- if( fp )
- {
- if( first )
- {
- first = 0;
- fprintf( fp, "Process ID: %ld (0x%lx)\n", GetCurrentProcessId(), GetCurrentProcessId() );
- }
- time_t aclock;
- time( &aclock ); // Get time in seconds
- struct tm *newtime = localtime( &aclock ); // Convert time to struct tm form
- fprintf( fp, asctime( newtime ) ); // print time stamp
-
- fprintf( fp, "%s returned %lu (0x%lx)\n", szApiCall, lastError, lastError );
- bSuccess = TRUE; // may be FormatMessage fails but we wrote at least the error code
-
- LPVOID lpMsgBuf;
- if (FormatMessageA(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- lastError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPSTR) &lpMsgBuf,
- 0,
- NULL ))
- {
- fprintf( fp, " %s\n", (LPSTR)lpMsgBuf );
- LocalFree( lpMsgBuf );
- }
-
- fclose( fp );
- }
- }
- return bSuccess;
+#if OSL_DEBUG_LEVEL > 0
+ LPVOID lpMsgBuf;
+ if (FormatMessageA(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ lastError & 0xffff,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL ))
+ {
+ SAL_WARN("vcl", "API call: " << szApiCall << " returned " << lastError << " (0x" << std::hex << lastError << "): " << (LPTSTR) lpMsgBuf);
+ LocalFree(lpMsgBuf);
}
else
- return TRUE;
+ SAL_WARN("vcl", "API call: " << szApiCall << " returned " << lastError << " (0x" << std::hex << lastError << ")");
+#endif
}
#ifdef _WIN32