aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-11-01 16:43:59 -0600
committerSean Hall <r.sean.hall@gmail.com>2020-11-01 18:35:01 -0600
commit352aefb0ac67ffbf74cd126db710031d4944fe89 (patch)
treeaed6e7fc95df4ba14902e4e3d97d19e5d4675695 /src
parent4921664f92bb6bd39ed7fd3dd24d58108973af25 (diff)
downloadwix-352aefb0ac67ffbf74cd126db710031d4944fe89.tar.gz
wix-352aefb0ac67ffbf74cd126db710031d4944fe89.tar.bz2
wix-352aefb0ac67ffbf74cd126db710031d4944fe89.zip
WIXFEAT:3816-Format variables and respect absolute paths in Log/@Prefix
Diffstat (limited to 'src')
-rw-r--r--src/engine/logging.cpp54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/engine/logging.cpp b/src/engine/logging.cpp
index a6412da9..e69303f0 100644
--- a/src/engine/logging.cpp
+++ b/src/engine/logging.cpp
@@ -33,6 +33,7 @@ extern "C" HRESULT LoggingOpen(
33{ 33{
34 HRESULT hr = S_OK; 34 HRESULT hr = S_OK;
35 LPWSTR sczLoggingBaseFolder = NULL; 35 LPWSTR sczLoggingBaseFolder = NULL;
36 LPWSTR sczPrefixFormatted = NULL;
36 37
37 // Check if the logging policy is set and configure the logging appropriately. 38 // Check if the logging policy is set and configure the logging appropriately.
38 CheckLoggingPolicy(&pLog->dwAttributes); 39 CheckLoggingPolicy(&pLog->dwAttributes);
@@ -103,30 +104,50 @@ extern "C" HRESULT LoggingOpen(
103 pLog->state = BURN_LOGGING_STATE_OPEN; 104 pLog->state = BURN_LOGGING_STATE_OPEN;
104 } 105 }
105 } 106 }
106 else if (pLog->sczPrefix && *pLog->sczPrefix) 107 else
107 { 108 {
108 hr = GetNonSessionSpecificTempFolder(&sczLoggingBaseFolder); 109 if (pLog->sczPrefix && *pLog->sczPrefix)
109 ExitOnFailure(hr, "Failed to get non-session specific TEMP folder."); 110 {
111 hr = VariableFormatString(pVariables, pLog->sczPrefix, &sczPrefixFormatted, NULL);
112 }
110 113
111 // Best effort to open default logging. 114 if (sczPrefixFormatted && *sczPrefixFormatted)
112 hr = LogOpen(sczLoggingBaseFolder, pLog->sczPrefix, NULL, pLog->sczExtension, FALSE, FALSE, &pLog->sczPath);
113 if (FAILED(hr))
114 { 115 {
115 LogDisable(); 116 LPCWSTR wzPrefix = sczPrefixFormatted;
116 pLog->state = BURN_LOGGING_STATE_DISABLED; 117
118 // Best effort to open default logging.
119 if (PathIsAbsolute(sczPrefixFormatted))
120 {
121 hr = PathGetDirectory(sczPrefixFormatted, &sczLoggingBaseFolder);
122 ExitOnFailure(hr, "Failed to get parent directory from '%ls'.", sczPrefixFormatted);
123
124 wzPrefix = PathFile(sczPrefixFormatted);
125 }
126 else
127 {
128 hr = GetNonSessionSpecificTempFolder(&sczLoggingBaseFolder);
129 ExitOnFailure(hr, "Failed to get non-session specific TEMP folder.");
130 }
117 131
118 hr = S_OK; 132 hr = LogOpen(sczLoggingBaseFolder, wzPrefix, NULL, pLog->sczExtension, FALSE, FALSE, &pLog->sczPath);
133 if (FAILED(hr))
134 {
135 LogDisable();
136 pLog->state = BURN_LOGGING_STATE_DISABLED;
137
138 hr = S_OK;
139 }
140 else
141 {
142 pLog->state = BURN_LOGGING_STATE_OPEN;
143 }
119 } 144 }
120 else 145 else // no logging enabled.
121 { 146 {
122 pLog->state = BURN_LOGGING_STATE_OPEN; 147 LogDisable();
148 pLog->state = BURN_LOGGING_STATE_DISABLED;
123 } 149 }
124 } 150 }
125 else // no logging enabled.
126 {
127 LogDisable();
128 pLog->state = BURN_LOGGING_STATE_DISABLED;
129 }
130 151
131 // If the log was opened, write the header info and update the prefix and extension to match 152 // If the log was opened, write the header info and update the prefix and extension to match
132 // the log name so future logs are opened with the same pattern. 153 // the log name so future logs are opened with the same pattern.
@@ -155,6 +176,7 @@ extern "C" HRESULT LoggingOpen(
155 176
156LExit: 177LExit:
157 ReleaseStr(sczLoggingBaseFolder); 178 ReleaseStr(sczLoggingBaseFolder);
179 StrSecureZeroFreeString(sczPrefixFormatted);
158 180
159 return hr; 181 return hr;
160} 182}