Skip to content

Commit

Permalink
Explicitly close file stream on FileLogger destruction (#3424)
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft authored Jul 11, 2023
1 parent b82cf60 commit bb0a746
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AppInstallerCommonCore/FileLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace AppInstaller::Logging
FileLogger::~FileLogger()
{
m_stream.flush();
// When std::ofstream is constructed from an existing File handle, it does not call fclose on destruction
// Only calling close() explicitly will close the file handle.
m_stream.close();
}

std::string FileLogger::GetNameForPath(const std::filesystem::path& filePath)
Expand Down

0 comments on commit bb0a746

Please sign in to comment.