Write source file and line in the setup install log

svn path=/trunk/; revision=27587
This commit is contained in:
Hervé Poussineau 2007-07-11 09:04:22 +00:00
parent 3a9951f710
commit 01e4b9b9ac
4 changed files with 56 additions and 34 deletions

View file

@ -16,8 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* PURPOSE: Log file functions * PURPOSE: Log file functions
@ -33,7 +32,6 @@
#include <syssetup/syssetup.h> #include <syssetup/syssetup.h>
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
HANDLE hLogFile = NULL; HANDLE hLogFile = NULL;
@ -41,28 +39,26 @@ HANDLE hLogFile = NULL;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
BOOL STDCALL BOOL WINAPI
InitializeSetupActionLog (BOOL bDeleteOldLogFile) InitializeSetupActionLog (BOOL bDeleteOldLogFile)
{ {
WCHAR szFileName[MAX_PATH]; WCHAR szFileName[MAX_PATH];
GetWindowsDirectoryW (szFileName, GetWindowsDirectoryW(szFileName, MAX_PATH);
MAX_PATH);
if (szFileName[wcslen (szFileName)] != L'\\') if (szFileName[wcslen(szFileName)] != L'\\')
{ {
wcsncat(szFileName, wcsncat(szFileName,
L"\\", L"\\",
MAX_PATH); MAX_PATH);
} }
wcsncat(szFileName, wcsncat(szFileName,
L"setuplog.txt", L"setuplog.txt",
MAX_PATH); MAX_PATH);
if (bDeleteOldLogFile != FALSE) if (bDeleteOldLogFile)
{ {
SetFileAttributesW(szFileName, SetFileAttributesW(szFileName, FILE_ATTRIBUTE_NORMAL);
FILE_ATTRIBUTE_NORMAL);
DeleteFileW(szFileName); DeleteFileW(szFileName);
} }
@ -83,8 +79,8 @@ InitializeSetupActionLog (BOOL bDeleteOldLogFile)
} }
VOID STDCALL VOID WINAPI
TerminateSetupActionLog (VOID) TerminateSetupActionLog(VOID)
{ {
if (hLogFile != NULL) if (hLogFile != NULL)
{ {
@ -94,16 +90,19 @@ TerminateSetupActionLog (VOID)
} }
BOOL STDCALL BOOL WINAPI
LogItem(DWORD dwSeverity, SYSSETUP_LogItem(IN const LPSTR lpFileName,
LPWSTR lpMessageText) IN DWORD dwLineNumber,
IN DWORD dwSeverity,
IN LPWSTR lpMessageText)
{ {
LPSTR lpNewLine = "\r\n"; const LPCSTR lpNewLine = "\r\n";
LPSTR lpSeverityString; LPCSTR lpSeverityString;
LPSTR lpMessageString; LPSTR lpMessageString;
DWORD dwMessageLength; DWORD dwMessageLength;
DWORD dwMessageSize; DWORD dwMessageSize;
DWORD dwWritten; DWORD dwWritten;
CHAR Buffer[6];
/* Get the severity code string */ /* Get the severity code string */
switch (dwSeverity) switch (dwSeverity)
@ -136,13 +135,11 @@ LogItem(DWORD dwSeverity,
dwMessageLength); dwMessageLength);
/* Allocate message string buffer */ /* Allocate message string buffer */
lpMessageString = (LPSTR) HeapAlloc(GetProcessHeap (), lpMessageString = (LPSTR) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
dwMessageSize); dwMessageSize);
if (lpMessageString == NULL) if (!lpMessageString)
{
return FALSE; return FALSE;
}
/* Convert unicode to ansi */ /* Convert unicode to ansi */
RtlUnicodeToMultiByteN(lpMessageString, RtlUnicodeToMultiByteN(lpMessageString,
@ -157,6 +154,27 @@ LogItem(DWORD dwSeverity,
NULL, NULL,
FILE_END); FILE_END);
/* Write file name */
WriteFile(hLogFile,
lpFileName,
strlen(lpFileName),
&dwWritten,
NULL);
/* 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 */ /* Write severity code */
WriteFile(hLogFile, WriteFile(hLogFile,
lpSeverityString, lpSeverityString,
@ -174,7 +192,7 @@ LogItem(DWORD dwSeverity,
/* Write newline */ /* Write newline */
WriteFile(hLogFile, WriteFile(hLogFile,
lpNewLine, lpNewLine,
2, sizeof(lpNewLine),
&dwWritten, &dwWritten,
NULL); NULL);

View file

@ -7,7 +7,7 @@ InitializeSetupActionLog@4
InstallLiveCD@4 InstallLiveCD@4
InstallReactOS@4 InstallReactOS@4
KeyboardClassInstaller@12 KeyboardClassInstaller@12
LogItem@8 ;LogItem@8
;LogItem0 ;LogItem0
;LogItem1 ;LogItem1
;LogItem2 ;LogItem2

View file

@ -572,7 +572,7 @@ ComputerPageDlgProc(HWND hwndDlg,
TCHAR Password2[15]; TCHAR Password2[15];
PWCHAR Password; PWCHAR Password;
WCHAR Title[64]; WCHAR Title[64];
WCHAR EmptyComputerName[256], EmptyPassword[256], NotMatchPassword[256], WrongPassword[256]; WCHAR EmptyComputerName[256], NotMatchPassword[256], WrongPassword[256];
DWORD Length; DWORD Length;
LPNMHDR lpnm; LPNMHDR lpnm;

View file

@ -39,16 +39,20 @@ InstallReactOS (HINSTANCE hInstance);
#define SYSSETUP_SEVERITY_FATAL_ERROR 3 #define SYSSETUP_SEVERITY_FATAL_ERROR 3
BOOL STDCALL BOOL WINAPI
InitializeSetupActionLog (BOOL bDeleteOldLogFile); InitializeSetupActionLog(IN BOOL bDeleteOldLogFile);
VOID STDCALL VOID WINAPI
TerminateSetupActionLog (VOID); TerminateSetupActionLog(VOID);
BOOL STDCALL BOOL WINAPI
LogItem (DWORD dwSeverity, SYSSETUP_LogItem(IN const LPSTR lpFileName,
LPWSTR lpMessageText); IN DWORD dwLineNumber,
IN DWORD dwSeverity,
IN LPWSTR lpMessageText);
#define LogItem(dwSeverity, lpMessageText) \
SYSSETUP_LogItem(__FILE__, __LINE__, dwSeverity, lpMessageText)
#endif /* __SYSSETUP_H_INCLUDED__ */ #endif /* __SYSSETUP_H_INCLUDED__ */