diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-01 21:27:43 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-07-01 21:43:26 +1000 |
| commit | 44355b6fa5c92a00f0d2fb33ba627a25f052664b (patch) | |
| tree | 96f9800750ca62887739aa2cec039ef57869a372 /src | |
| parent | fd385c79b4f00ebe897e864481669295d8fc112c (diff) | |
| download | wix-44355b6fa5c92a00f0d2fb33ba627a25f052664b.tar.gz wix-44355b6fa5c92a00f0d2fb33ba627a25f052664b.tar.bz2 wix-44355b6fa5c92a00f0d2fb33ba627a25f052664b.zip | |
Add BalLogArgs and BalLogErrorArgs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/balutil/balutil.cpp | 50 | ||||
| -rw-r--r-- | src/balutil/inc/balutil.h | 20 |
2 files changed, 66 insertions, 4 deletions
diff --git a/src/balutil/balutil.cpp b/src/balutil/balutil.cpp index df254359..7567752c 100644 --- a/src/balutil/balutil.cpp +++ b/src/balutil/balutil.cpp | |||
| @@ -251,6 +251,29 @@ DAPIV_(HRESULT) BalLog( | |||
| 251 | { | 251 | { |
| 252 | HRESULT hr = S_OK; | 252 | HRESULT hr = S_OK; |
| 253 | va_list args; | 253 | va_list args; |
| 254 | |||
| 255 | if (!vpEngine) | ||
| 256 | { | ||
| 257 | hr = E_POINTER; | ||
| 258 | ExitOnRootFailure(hr, "BalInitialize() must be called first."); | ||
| 259 | } | ||
| 260 | |||
| 261 | va_start(args, szFormat); | ||
| 262 | hr = BalLogArgs(level, szFormat, args); | ||
| 263 | va_end(args); | ||
| 264 | |||
| 265 | LExit: | ||
| 266 | return hr; | ||
| 267 | } | ||
| 268 | |||
| 269 | |||
| 270 | DAPI_(HRESULT) BalLogArgs( | ||
| 271 | __in BOOTSTRAPPER_LOG_LEVEL level, | ||
| 272 | __in_z __format_string LPCSTR szFormat, | ||
| 273 | __in va_list args | ||
| 274 | ) | ||
| 275 | { | ||
| 276 | HRESULT hr = S_OK; | ||
| 254 | LPSTR sczFormattedAnsi = NULL; | 277 | LPSTR sczFormattedAnsi = NULL; |
| 255 | LPWSTR sczMessage = NULL; | 278 | LPWSTR sczMessage = NULL; |
| 256 | 279 | ||
| @@ -260,9 +283,7 @@ DAPIV_(HRESULT) BalLog( | |||
| 260 | ExitOnRootFailure(hr, "BalInitialize() must be called first."); | 283 | ExitOnRootFailure(hr, "BalInitialize() must be called first."); |
| 261 | } | 284 | } |
| 262 | 285 | ||
| 263 | va_start(args, szFormat); | ||
| 264 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); | 286 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); |
| 265 | va_end(args); | ||
| 266 | ExitOnFailure(hr, "Failed to format log string."); | 287 | ExitOnFailure(hr, "Failed to format log string."); |
| 267 | 288 | ||
| 268 | hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); | 289 | hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); |
| @@ -285,6 +306,29 @@ DAPIV_(HRESULT) BalLogError( | |||
| 285 | { | 306 | { |
| 286 | HRESULT hr = S_OK; | 307 | HRESULT hr = S_OK; |
| 287 | va_list args; | 308 | va_list args; |
| 309 | |||
| 310 | if (!vpEngine) | ||
| 311 | { | ||
| 312 | hr = E_POINTER; | ||
| 313 | ExitOnRootFailure(hr, "BalInitialize() must be called first."); | ||
| 314 | } | ||
| 315 | |||
| 316 | va_start(args, szFormat); | ||
| 317 | hr = BalLogErrorArgs(hrError, szFormat, args); | ||
| 318 | va_end(args); | ||
| 319 | |||
| 320 | LExit: | ||
| 321 | return hr; | ||
| 322 | } | ||
| 323 | |||
| 324 | |||
| 325 | DAPI_(HRESULT) BalLogErrorArgs( | ||
| 326 | __in HRESULT hrError, | ||
| 327 | __in_z __format_string LPCSTR szFormat, | ||
| 328 | __in va_list args | ||
| 329 | ) | ||
| 330 | { | ||
| 331 | HRESULT hr = S_OK; | ||
| 288 | LPSTR sczFormattedAnsi = NULL; | 332 | LPSTR sczFormattedAnsi = NULL; |
| 289 | LPWSTR sczMessage = NULL; | 333 | LPWSTR sczMessage = NULL; |
| 290 | 334 | ||
| @@ -294,9 +338,7 @@ DAPIV_(HRESULT) BalLogError( | |||
| 294 | ExitOnRootFailure(hr, "BalInitialize() must be called first."); | 338 | ExitOnRootFailure(hr, "BalInitialize() must be called first."); |
| 295 | } | 339 | } |
| 296 | 340 | ||
| 297 | va_start(args, szFormat); | ||
| 298 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); | 341 | hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); |
| 299 | va_end(args); | ||
| 300 | ExitOnFailure(hr, "Failed to format error log string."); | 342 | ExitOnFailure(hr, "Failed to format error log string."); |
| 301 | 343 | ||
| 302 | hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); | 344 | hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); |
diff --git a/src/balutil/inc/balutil.h b/src/balutil/inc/balutil.h index 68ef5a4d..e0f5874c 100644 --- a/src/balutil/inc/balutil.h +++ b/src/balutil/inc/balutil.h | |||
| @@ -145,6 +145,16 @@ DAPIV_(HRESULT) BalLog( | |||
| 145 | ); | 145 | ); |
| 146 | 146 | ||
| 147 | /******************************************************************* | 147 | /******************************************************************* |
| 148 | BalLogArgs - logs a message with the engine. | ||
| 149 | |||
| 150 | ********************************************************************/ | ||
| 151 | DAPI_(HRESULT) BalLogArgs( | ||
| 152 | __in BOOTSTRAPPER_LOG_LEVEL level, | ||
| 153 | __in_z __format_string LPCSTR szFormat, | ||
| 154 | __in va_list args | ||
| 155 | ); | ||
| 156 | |||
| 157 | /******************************************************************* | ||
| 148 | BalLogError - logs an error message with the engine. | 158 | BalLogError - logs an error message with the engine. |
| 149 | 159 | ||
| 150 | ********************************************************************/ | 160 | ********************************************************************/ |
| @@ -155,6 +165,16 @@ DAPIV_(HRESULT) BalLogError( | |||
| 155 | ); | 165 | ); |
| 156 | 166 | ||
| 157 | /******************************************************************* | 167 | /******************************************************************* |
| 168 | BalLogErrorArgs - logs an error message with the engine. | ||
| 169 | |||
| 170 | ********************************************************************/ | ||
| 171 | DAPI_(HRESULT) BalLogErrorArgs( | ||
| 172 | __in HRESULT hr, | ||
| 173 | __in_z __format_string LPCSTR szFormat, | ||
| 174 | __in va_list args | ||
| 175 | ); | ||
| 176 | |||
| 177 | /******************************************************************* | ||
| 158 | BalLogId - logs a message with the engine with a string embedded in a | 178 | BalLogId - logs a message with the engine with a string embedded in a |
| 159 | MESSAGETABLE resource. | 179 | MESSAGETABLE resource. |
| 160 | 180 | ||
