Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that log files are written to before crashing #495

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modules/common/chowdsp_logging/Loggers/chowdsp_LogFileHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@
void shutdownLogger (int signal)
{
juce::Logger::writeToLog (toString (signal == 0 ? exitString : crashString));

if (auto* logger = dynamic_cast<BaseLogger*> (juce::Logger::getCurrentLogger()))
{
try
{
logger->internal_logger.flush();
}
catch ([[maybe_unused]] const spdlog::spdlog_ex& ex)

Check warning on line 73 in modules/common/chowdsp_logging/Loggers/chowdsp_LogFileHelpers.cpp

View check run for this annotation

Codecov / codecov/patch

modules/common/chowdsp_logging/Loggers/chowdsp_LogFileHelpers.cpp#L73

Added line #L73 was not covered by tests
{
jassertfalse;

Check warning on line 75 in modules/common/chowdsp_logging/Loggers/chowdsp_LogFileHelpers.cpp

View check run for this annotation

Codecov / codecov/patch

modules/common/chowdsp_logging/Loggers/chowdsp_LogFileHelpers.cpp#L75

Added line #L75 was not covered by tests
}
}

juce::Logger::setCurrentLogger (nullptr);
}
} // namespace LogFileHelpers
Expand Down
8 changes: 0 additions & 8 deletions modules/common/chowdsp_logging/Loggers/chowdsp_Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ Logger::Logger (const LogFileParams& loggerParams) : params (loggerParams)

Logger::~Logger()
{
try
{
logger.internal_logger.flush();
}
catch ([[maybe_unused]] const spdlog::spdlog_ex& ex)
{
jassertfalse;
}
LogFileHelpers::shutdownLogger();
}
} // namespace chowdsp
Loading