Create folders for debug log file (#6546)
This commit is contained in:
parent
5887e412c6
commit
26c78ee542
|
|
@ -123,7 +123,7 @@ void SetDebugFlags(const std::wstring &debugValue)
|
|||
}
|
||||
}
|
||||
|
||||
bool CreateDebugLogFile(const std::wstring &debugOutputFile)
|
||||
bool CreateDebugLogFile(const std::filesystem::path &debugOutputFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -140,6 +140,11 @@ bool CreateDebugLogFile(const std::wstring &debugOutputFile)
|
|||
CloseHandle(g_logFile);
|
||||
g_logFile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
// ignore errors
|
||||
std::error_code ec;
|
||||
create_directories(debugOutputFile.parent_path(), ec);
|
||||
|
||||
g_logFile = CreateFileW(debugOutputFile.c_str(),
|
||||
(GENERIC_READ | GENERIC_WRITE),
|
||||
(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
|
||||
|
|
@ -348,13 +353,13 @@ DebugPrintW(
|
|||
WORD eventType;
|
||||
switch (dwFlag)
|
||||
{
|
||||
case ASPNETCORE_DEBUG_FLAG_ERROR:
|
||||
case ASPNETCORE_DEBUG_FLAG_ERROR:
|
||||
eventType = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case ASPNETCORE_DEBUG_FLAG_WARNING:
|
||||
case ASPNETCORE_DEBUG_FLAG_WARNING:
|
||||
eventType = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
eventType = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,17 +85,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
|
||||
[ConditionalTheory]
|
||||
[MemberData(nameof(TestVariants))]
|
||||
[RequiresNewShim]
|
||||
public async Task StartupMessagesAreLoggedIntoDebugLogFile(TestVariant variant)
|
||||
{
|
||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
|
||||
deploymentParameters.HandlerSettings["debugLevel"] = "file";
|
||||
deploymentParameters.HandlerSettings["debugFile"] = "debug.txt";
|
||||
deploymentParameters.HandlerSettings["debugFile"] = "subdirectory\\debug.txt";
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
await deploymentResult.HttpClient.GetAsync("/");
|
||||
|
||||
AssertLogs(Path.Combine(deploymentResult.ContentRoot, "debug.txt"));
|
||||
AssertLogs(Path.Combine(deploymentResult.ContentRoot, "subdirectory", "debug.txt"));
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
|
|
|||
Loading…
Reference in New Issue