Flush logs on error

This commit is contained in:
crschnick 2024-03-14 09:34:53 +00:00
parent c6cca15a9a
commit e89fb97d53
2 changed files with 11 additions and 0 deletions

View file

@ -80,6 +80,12 @@ public class AppLogs {
hookUpSystemErr();
}
public void flush() {
if (outFileStream != null) {
outFileStream.flush();
}
}
private static boolean shouldWriteLogs() {
if (System.getProperty(WRITE_LOGS_PROP) != null) {
return Boolean.parseBoolean(System.getProperty(WRITE_LOGS_PROP));

View file

@ -111,6 +111,11 @@ public class SentryErrorHandler implements ErrorHandler {
private static void fillScope(ErrorEvent ee, IScope s) {
if (ee.isShouldSendDiagnostics()) {
// Write all buffered output to log files to ensure that we get all information
if (AppLogs.get() != null) {
AppLogs.get().flush();
}
var atts = ee.getAttachments().stream()
.map(d -> {
try {