Author: ekohl
Date: Thu Dec 31 22:17:45 2015
New Revision: 70474
URL:
http://svn.reactos.org/svn/reactos?rev=70474&view=rev
Log:
[SYSETUP]
- Implement pSetupDebugPrint and modify the LogItem macro accordingly.
- Add some log messages to the setup wizard.
Modified:
trunk/reactos/dll/win32/syssetup/install.c
trunk/reactos/dll/win32/syssetup/logfile.c
trunk/reactos/dll/win32/syssetup/syssetup.spec
trunk/reactos/dll/win32/syssetup/wizard.c
trunk/reactos/include/reactos/libs/syssetup/syssetup.h
Modified: trunk/reactos/dll/win32/syssetup/install.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] Thu Dec 31 22:17:45 2015
@@ -64,7 +64,7 @@
vsprintf(szBuffer, pszFmt, ap);
va_end(ap);
- LogItem(SYSSETUP_SEVERITY_FATAL_ERROR, L"Failed");
+ LogItem(NULL, L"Failed");
strcat(szBuffer, "\nRebooting now!");
MessageBoxA(NULL,
@@ -1097,7 +1097,7 @@
BOOL ret;
InitializeSetupActionLog(FALSE);
- LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
+ LogItem(NULL, L"Installing ReactOS");
if (!InitializeProfiles())
{
@@ -1194,7 +1194,7 @@
CloseHandle(hHotkeyThread);
}
- LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
+ LogItem(NULL, L"Installing ReactOS done");
TerminateSetupActionLog();
if (AdminInfo.Name != NULL)
Modified: trunk/reactos/dll/win32/syssetup/logfile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/logfile…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/logfile.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/logfile.c [iso-8859-1] Thu Dec 31 22:17:45 2015
@@ -27,10 +27,14 @@
/* INCLUDES *****************************************************************/
#include "precomp.h"
+#include <stdarg.h>
/* GLOBALS ******************************************************************/
HANDLE hLogFile = NULL;
+
+#define FORMAT_BUFFER_SIZE 512
+#define LINE_BUFFER_SIZE 1024
/* FUNCTIONS ****************************************************************/
@@ -85,64 +89,84 @@
}
-BOOL WINAPI
-SYSSETUP_LogItem(IN const LPSTR lpFileName,
- IN DWORD dwLineNumber,
- IN DWORD dwSeverity,
- IN LPWSTR lpMessageText)
+VOID
+CDECL
+pSetupDebugPrint(
+ IN PCWSTR pszFileName,
+ IN INT nLineNumber,
+ IN PCWSTR pszTag,
+ IN PCWSTR pszMessage,
+ ...)
{
- LPCSTR lpSeverityString;
- LPSTR lpMessageString;
- DWORD dwMessageLength;
- DWORD dwMessageSize;
+ PWSTR pszFormatBuffer = NULL;
+ PWSTR pszLineBuffer = NULL;
+ PSTR pszOutputBuffer = NULL;
+ ULONG ulLineSize, ulOutputSize;
DWORD dwWritten;
- CHAR Buffer[6];
- CHAR TimeBuffer[30];
SYSTEMTIME stTime;
+ va_list args;
- /* Get the severity code string */
- switch (dwSeverity)
+ if (hLogFile == NULL)
+ return;
+
+ GetLocalTime(&stTime);
+
+ if (pszMessage)
{
- case SYSSETUP_SEVERITY_INFORMATION:
- lpSeverityString = "Information : ";
- break;
+ pszFormatBuffer = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ FORMAT_BUFFER_SIZE * sizeof(WCHAR));
+ if (pszFormatBuffer == NULL)
+ goto done;
- case SYSSETUP_SEVERITY_WARNING:
- lpSeverityString = "Warning : ";
- break;
-
- case SYSSETUP_SEVERITY_ERROR:
- lpSeverityString = "Error : ";
- break;
-
- case SYSSETUP_SEVERITY_FATAL_ERROR:
- lpSeverityString = "Fatal error : ";
- break;
-
- default:
- lpSeverityString = "Unknown : ";
- break;
+ va_start(args, pszMessage);
+ vsnwprintf(pszFormatBuffer,
+ FORMAT_BUFFER_SIZE,
+ pszMessage,
+ args);
+ va_end(args);
}
+ pszLineBuffer = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ LINE_BUFFER_SIZE * sizeof(WCHAR));
+ if (pszLineBuffer == NULL)
+ goto done;
+
+ _snwprintf(pszLineBuffer,
+ LINE_BUFFER_SIZE,
+ L"%02d/%02d/%04d %02d:%02d:%02d.%03d, %s, %d, %s, %s\r\n",
+ stTime.wMonth,
+ stTime.wDay,
+ stTime.wYear,
+ stTime.wHour,
+ stTime.wMinute,
+ stTime.wSecond,
+ stTime.wMilliseconds,
+ pszFileName ? pszFileName : L"",
+ nLineNumber,
+ pszTag ? pszTag : L"",
+ pszFormatBuffer ? pszFormatBuffer : L"");
+
/* Get length of the converted ansi string */
- dwMessageLength = wcslen(lpMessageText) * sizeof(WCHAR);
- RtlUnicodeToMultiByteSize(&dwMessageSize,
- lpMessageText,
- dwMessageLength);
+ ulLineSize = wcslen(pszLineBuffer) * sizeof(WCHAR);
+ RtlUnicodeToMultiByteSize(&ulOutputSize,
+ pszLineBuffer,
+ ulLineSize);
/* Allocate message string buffer */
- lpMessageString = (LPSTR) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- dwMessageSize);
- if (!lpMessageString)
- return FALSE;
+ pszOutputBuffer = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ ulOutputSize);
+ if (pszOutputBuffer == NULL)
+ goto done;
/* Convert unicode to ansi */
- RtlUnicodeToMultiByteN(lpMessageString,
- dwMessageSize,
+ RtlUnicodeToMultiByteN(pszOutputBuffer,
+ ulOutputSize,
NULL,
- lpMessageText,
- dwMessageLength);
+ pszLineBuffer,
+ ulLineSize);
/* Set file pointer to the end of the file */
SetFilePointer(hLogFile,
@@ -150,71 +174,21 @@
NULL,
FILE_END);
- /* Write Time/Date */
- GetLocalTime(&stTime);
-
- snprintf(TimeBuffer, sizeof(TimeBuffer),
- "%02d/%02d/%02d %02d:%02d:%02d.%03d",
- stTime.wMonth,
- stTime.wDay,
- stTime.wYear,
- stTime.wHour,
- stTime.wMinute,
- stTime.wSecond,
- stTime.wMilliseconds);
-
WriteFile(hLogFile,
- TimeBuffer,
- strlen(TimeBuffer),
+ pszOutputBuffer,
+ ulOutputSize,
&dwWritten,
NULL);
- /* Write comma */
- WriteFile(hLogFile, ",", 1, &dwWritten, NULL);
+done:
+ if (pszOutputBuffer)
+ HeapFree(GetProcessHeap(), 0, pszOutputBuffer);
- /* Write file name */
- WriteFile(hLogFile,
- lpFileName,
- strlen(lpFileName),
- &dwWritten,
- NULL);
+ if (pszLineBuffer)
+ HeapFree(GetProcessHeap(), 0, pszLineBuffer);
- /* Write comma */
- WriteFile(hLogFile, ",", 1, &dwWritten, NULL);
-
- /* Write line number */
- snprintf(Buffer, sizeof(Buffer), "%lu", dwLineNumber);
- WriteFile(hLogFile,
- Buffer,
- strlen(Buffer),
- &dwWritten,
- NULL);
-
- /* Write comma */
- WriteFile(hLogFile, ",", 1, &dwWritten, NULL);
-
- /* Write severity code */
- WriteFile(hLogFile,
- lpSeverityString,
- strlen(lpSeverityString),
- &dwWritten,
- NULL);
-
- /* Write message string */
- WriteFile(hLogFile,
- lpMessageString,
- dwMessageSize,
- &dwWritten,
- NULL);
-
- /* Write newline */
- WriteFile(hLogFile, "\r\n", 2, &dwWritten, NULL);
-
- HeapFree(GetProcessHeap(),
- 0,
- lpMessageString);
-
- return TRUE;
+ if (pszFormatBuffer)
+ HeapFree(GetProcessHeap(), 0, pszFormatBuffer);
}
/* EOF */
Modified: trunk/reactos/dll/win32/syssetup/syssetup.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/syssetu…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/syssetup.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/syssetup.spec [iso-8859-1] Thu Dec 31 22:17:45 2015
@@ -83,5 +83,5 @@
@ stub UpgradePrinters
@ stub ViewSetupActionLog
@ stdcall VolumeClassInstaller(long ptr ptr)
-@ stub pSetupDebugPrint
+@ varargs pSetupDebugPrint(wstr long wstr wstr)
@ stub pSetuplogSfcError
Modified: trunk/reactos/dll/win32/syssetup/wizard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] Thu Dec 31 22:17:45 2015
@@ -266,6 +266,7 @@
switch (lpnm->code)
{
case PSN_SETACTIVE:
+ LogItem(L"BEGIN", L"WelcomePage");
/* Enable the Next button */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
if (pSetupData->UnattendSetup)
@@ -273,6 +274,10 @@
SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_ACKPAGE);
return TRUE;
}
+ break;
+
+ case PSN_WIZNEXT:
+ LogItem(L"END", L"WelcomePage");
break;
case PSN_WIZBACK:
@@ -2302,7 +2307,7 @@
if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
{
/* buffer too small or failure */
- LogItem(SYSSETUP_SEVERITY_INFORMATION, L"GetLogicalDriveStringsW
failed");
+ LogItem(NULL, L"GetLogicalDriveStringsW failed");
return FALSE;
}
@@ -2312,7 +2317,7 @@
{
WCHAR wszBuf[MAX_PATH];
wsprintf(wszBuf, L"%sreactos\\system32\\ntoskrnl.exe", pwszDrive);
- LogItem(SYSSETUP_SEVERITY_INFORMATION, wszBuf);
+ LogItem(NULL, wszBuf);
if (GetFileAttributesW(wszBuf) != INVALID_FILE_ATTRIBUTES)
{
/* the file exists, so this is the right drive */
@@ -2372,12 +2377,15 @@
MSG msg;
PSETUPDATA pSetupData = NULL;
+ LogItem(L"BEGIN_SECTION", L"InstallWizard");
+
/* Allocate setup data */
pSetupData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(SETUPDATA));
if (pSetupData == NULL)
{
+ LogItem(NULL, L"SetupData allocation failed!");
MessageBoxW(NULL,
L"Setup failed to allocate global data!",
L"ReactOS Setup",
@@ -2487,6 +2495,8 @@
DeleteObject(pSetupData->hTitleFont);
HeapFree(GetProcessHeap(), 0, pSetupData);
+
+ LogItem(L"END_SECTION", L"InstallWizard");
}
/* EOF */
Modified: trunk/reactos/include/reactos/libs/syssetup/syssetup.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/sysse…
==============================================================================
--- trunk/reactos/include/reactos/libs/syssetup/syssetup.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/syssetup/syssetup.h [iso-8859-1] Thu Dec 31
22:17:45 2015
@@ -31,26 +31,27 @@
/* Log File APIs */
-#define SYSSETUP_SEVERITY_INFORMATION 0
-#define SYSSETUP_SEVERITY_WARNING 1
-#define SYSSETUP_SEVERITY_ERROR 2
-#define SYSSETUP_SEVERITY_FATAL_ERROR 3
-
-
BOOL WINAPI
InitializeSetupActionLog(IN BOOL bDeleteOldLogFile);
VOID WINAPI
TerminateSetupActionLog(VOID);
-BOOL WINAPI
-SYSSETUP_LogItem(IN const LPSTR lpFileName,
- IN DWORD dwLineNumber,
- IN DWORD dwSeverity,
- IN LPWSTR lpMessageText);
+VOID
+CDECL
+pSetupDebugPrint(
+ IN PCWSTR pszFileName,
+ IN INT nLineNumber,
+ IN PCWSTR pszTag,
+ IN PCWSTR pszMessage,
+ ...);
-#define LogItem(dwSeverity, lpMessageText) \
- SYSSETUP_LogItem(__FILE__, __LINE__, dwSeverity, lpMessageText)
+#define __WFILE__ TOWL1(__FILE__)
+#define TOWL1(p) TOWL2(p)
+#define TOWL2(p) L##p
+
+#define LogItem(lpTag, lpMessageText...) \
+ pSetupDebugPrint(__WFILE__, __LINE__, lpTag, lpMessageText)
#endif /* __SYSSETUP_H_INCLUDED__ */