diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index 00b3135f..03942b51 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -221,7 +221,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, ret = ui_doinstall(); #ifdef NSIS_CONFIG_LOG +#ifndef NSIS_CONFIG_LOG_ODS log_write(1); +#endif//!NSIS_CONFIG_LOG_ODS #endif//NSIS_CONFIG_LOG end: diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 3a0f8c96..adc378e7 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -123,11 +123,13 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara #endif//!NSIS_CONFIG_ENHANCEDUI_SUPPORT #ifdef NSIS_CONFIG_LOG +#ifndef NSIS_CONFIG_LOG_ODS void NSISCALL build_g_logfile() { lstrcat(addtrailingslash(mystrcpy(g_log_file,state_install_directory)),"install.log"); } #endif +#endif int *cur_langtable; @@ -225,7 +227,9 @@ int NSISCALL ui_doinstall(void) #ifdef NSIS_CONFIG_LOG if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller) { +#ifndef NSIS_CONFIG_LOG_ODS build_g_logfile(); +#endif log_dolog=1; } #endif @@ -754,7 +758,9 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar GetUIText(IDC_DIR,dir,NSIS_MAX_STRLEN); validate_filename(dir); #ifdef NSIS_CONFIG_LOG +#ifndef NSIS_CONFIG_LOG_ODS build_g_logfile(); +#endif log_dolog = IsDlgButtonChecked(hwndDlg,IDC_CHECK1); #endif } diff --git a/Source/exehead/config.h b/Source/exehead/config.h index 8174ca27..c8451c89 100644 --- a/Source/exehead/config.h +++ b/Source/exehead/config.h @@ -115,7 +115,12 @@ // turning this on (by uncommenting it) adds about // 4kb, but can be useful in debugging your installers. // NOT ENABLED BY DEFAULT. -//#define NSIS_CONFIG_LOG +// #define NSIS_CONFIG_LOG + +// NSIS_CONFIG_LOG_ODS makes the logging facility +// use OutputDebugString instead of a file. +// NOT ENABLED BY DEFAULT. +// #define NSIS_CONFIG_LOG_ODS // NSIS_SUPPORT_BGBG enables support for the blue (well, whatever // color you want) gradient background window. @@ -275,6 +280,11 @@ #endif #endif +#ifdef NSIS_CONFIG_LOG_ODS + #ifndef NSIS_CONFIG_LOG + #error NSIS_CONFIG_LOG_ODS relies on NSIS_CONFIG_LOG, but NSIS_CONFIG_LOG is not defined + #endif +#endif #if defined(NSIS_CONFIG_CRC_SUPPORT) && defined(NSIS_CONFIG_VISIBLE_SUPPORT) #define _NSIS_CONFIG_VERIFYDIALOG diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 50213d4f..c725f430 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -1476,7 +1476,9 @@ static int NSISCALL ExecuteEntry(entry *entry_) log_printf2("settings logging to %d",parm1); log_dolog=parm1; log_printf2("logging set to %d",parm1); +#ifndef NSIS_CONFIG_LOG_ODS if (parm1) build_g_logfile(); +#endif } else { diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 3da5e422..6fb56514 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -11,8 +11,10 @@ #include "ui.h" #ifdef NSIS_CONFIG_LOG +#ifndef NSIS_CONFIG_LOG_ODS char g_log_file[1024]; #endif +#endif #ifdef NSIS_SUPPORT_NAMED_USERVARS // *** DO NOT DECLARE MORE VARIABLES INSIDE THIS PRAGMAS *** @@ -722,11 +724,12 @@ char * NSISCALL validate_filename(char *in) { } #ifdef NSIS_CONFIG_LOG -char log_text[4096]; int log_dolog; +char log_text[NSIS_MAX_STRLEN*4]; + +#ifndef NSIS_CONFIG_LOG_ODS void NSISCALL log_write(int close) { - extern char g_log_file[1024]; static HANDLE fp=INVALID_HANDLE_VALUE; if (close) { @@ -753,7 +756,22 @@ void NSISCALL log_write(int close) } } } +#endif//!NSIS_CONFIG_LOG_ODS + +void log_printf(char *format, ...) +{ + va_list val; + va_start(val,format); + wvsprintf(log_text,format,val); + va_end(val); +#ifdef NSIS_CONFIG_LOG_ODS + if (log_dolog) + OutputDebugString(log_text); +#else + log_write(0); #endif +} +#endif//NSIS_CONFIG_LOG WIN32_FIND_DATA * NSISCALL file_exists(char *buf) { diff --git a/Source/exehead/util.h b/Source/exehead/util.h index 3f1b0b5d..e4d08ec4 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -25,13 +25,14 @@ BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val); #ifdef NSIS_CONFIG_LOG extern char log_text[NSIS_MAX_STRLEN*4]; void NSISCALL log_write(int close); -#define log_printf(x1) wsprintf(log_text,x1); log_write(0) -#define log_printf2(x1,x2) wsprintf(log_text,x1,x2); log_write(0) -#define log_printf3(x1,x2,x3) wsprintf(log_text,x1,x2,x3); log_write(0) -#define log_printf4(x1,x2,x3,x4) wsprintf(log_text,x1,x2,x3,x4); log_write(0) -#define log_printf5(x1,x2,x3,x4,x5) wsprintf(log_text,x1,x2,x3,x4,x5); log_write(0) -#define log_printf6(x1,x2,x3,x4,x5,x6) wsprintf(log_text,x1,x2,x3,x4,x5,x6); log_write(0) -#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8) wsprintf(log_text,x1,x2,x3,x4,x5,x6,x7,x8); log_write(0) +void log_printf(char *format, ...); +#define log_printf2(x1,x2) wsprintf(log_text,x1,x2); +#define log_printf3(x1,x2,x3) wsprintf(log_text,x1,x2,x3); +#define log_printf4(x1,x2,x3,x4) wsprintf(log_text,x1,x2,x3,x4); +#define log_printf5(x1,x2,x3,x4,x5) wsprintf(log_text,x1,x2,x3,x4,x5); +#define log_printf6(x1,x2,x3,x4,x5,x6) wsprintf(log_text,x1,x2,x3,x4,x5,x6); +#define log_printf6(x1,x2,x3,x4,x5,x6,x7) wsprintf(log_text,x1,x2,x3,x4,x5,x6,x7); +#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8) wsprintf(log_text,x1,x2,x3,x4,x5,x6,x7,x8); extern int log_dolog; extern char g_log_file[1024]; #else