Aggiunto invio del file raw del log nel caso in cui vada in eccezione il parsine
This commit is contained in:
parent
819cc97113
commit
ce9d304043
@ -280,6 +280,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
|||||||
List<MailAttachmentDTO> attachmentDTOList = new ArrayList<>();
|
List<MailAttachmentDTO> attachmentDTOList = new ArrayList<>();
|
||||||
|
|
||||||
if (fileToShare != null) {
|
if (fileToShare != null) {
|
||||||
|
try {
|
||||||
var htmlContent = createAppLogAttachment(fileToShare);
|
var htmlContent = createAppLogAttachment(fileToShare);
|
||||||
|
|
||||||
byte[] buffer = htmlContent.getBytes();//specify the size to allow.
|
byte[] buffer = htmlContent.getBytes();//specify the size to allow.
|
||||||
@ -289,6 +290,17 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
|||||||
.setFileName("wms_log.html")
|
.setFileName("wms_log.html")
|
||||||
.setFileb64Content(base64);
|
.setFileb64Content(base64);
|
||||||
attachmentDTOList.add(logAttachment);
|
attachmentDTOList.add(logAttachment);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
String rawLogFile = getRawLogAttachment(fileToShare);
|
||||||
|
|
||||||
|
byte[] buffer = rawLogFile.getBytes();//specify the size to allow.
|
||||||
|
String base64 = Base64.encodeToString(buffer, Base64.NO_WRAP);
|
||||||
|
|
||||||
|
var logAttachment = new MailAttachmentDTO()
|
||||||
|
.setFileName("raw_log.txt")
|
||||||
|
.setFileb64Content(base64);
|
||||||
|
attachmentDTOList.add(logAttachment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -461,4 +473,24 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
|||||||
|
|
||||||
return htmlContent.toString();
|
return htmlContent.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getRawLogAttachment(File logFile) {
|
||||||
|
//Read text from file
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader br = new BufferedReader(new FileReader(logFile));
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
text.append(line);
|
||||||
|
text.append('\n');
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
//You'll need to add proper error handling here
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user