From bb18c9c4f0e6da640775b85ebda68b31f2b391ed Mon Sep 17 00:00:00 2001 From: Nir Bar Date: Thu, 12 Aug 2021 14:16:01 -0500 Subject: Set the log file path for MSI transactions. --- src/burn/engine/logging.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src/burn/engine/logging.cpp') diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp index 9aaf60ed..33295acd 100644 --- a/src/burn/engine/logging.cpp +++ b/src/burn/engine/logging.cpp @@ -242,11 +242,6 @@ extern "C" HRESULT LoggingSetPackageVariable( // Make sure that no package log files are created when logging has been disabled via Log element. if (BURN_LOGGING_STATE_DISABLED == pLog->state) { - if (psczLogPath) - { - *psczLogPath = NULL; - } - ExitFunction(); } @@ -272,6 +267,36 @@ LExit: return hr; } +extern "C" HRESULT LoggingSetTransactionVariable( + __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary, + __in_z_opt LPCWSTR wzSuffix, + __in BURN_LOGGING* pLog, + __in BURN_VARIABLES* pVariables + ) +{ + HRESULT hr = S_OK; + + // Make sure that no log files are created when logging has been disabled via Log element. + if (BURN_LOGGING_STATE_DISABLED == pLog->state) + { + ExitFunction(); + } + + if (pRollbackBoundary && pRollbackBoundary->sczLogPathVariable && *pRollbackBoundary->sczLogPathVariable) + { + hr = StrAllocFormatted(&pRollbackBoundary->sczLogPath, L"%ls%hs%ls_%03u_%ls.%ls", pLog->sczPrefix, wzSuffix && *wzSuffix ? "_" : "", wzSuffix && *wzSuffix ? wzSuffix : L"", vdwPackageSequence, pRollbackBoundary->sczId, pLog->sczExtension); + ExitOnFailure(hr, "Failed to allocate path for transaction log."); + + hr = VariableSetString(pVariables, pRollbackBoundary->sczLogPathVariable, pRollbackBoundary->sczLogPath, FALSE, FALSE); + ExitOnFailure(hr, "Failed to set log path into variable."); + } + +LExit: + ++vdwPackageSequence; + + return hr; +} + extern "C" LPCSTR LoggingBurnActionToString( __in BOOTSTRAPPER_ACTION action ) -- cgit v1.2.3-55-g6feb