Flush logs on error

This commit is contained in:
crschnick committed 2024-03-14 09:34:53 +00:00
1 parent c6cca15a9a
commit e89fb97d53
2 files changed
+11

No files matched your search

@@ -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));
@@ -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 {