Enabled logcat

pull/214/head
M66B 8 months ago
parent 7b42fb1ea6
commit 566ca91f0c

@ -1308,38 +1308,36 @@ public class DebugHelper {
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
attachment.zip(context, FairEmailLoggingProvider.getLogFiles(context)); List<File> files = new ArrayList<>();
/* files.addAll(Arrays.asList(FairEmailLoggingProvider.getLogFiles(context)));
File logcat = new File(context.getFilesDir(), "logcat.txt");
// https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html#java // https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html#java
ProcessBuilder pb = new ProcessBuilder("/system/bin/logcat", ProcessBuilder pb = new ProcessBuilder("logcat", // CASA "/system/bin/logcat",
"-d", "-d",
"-v", "threadtime", "-v", "threadtime",
//"-t", "1000", //"-t", "1000",
Log.TAG + ":I"); "fairemail" + ":I");
Map<String, String> env = pb.environment(); Map<String, String> env = pb.environment();
env.clear(); env.clear();
pb.directory(context.getFilesDir()); pb.directory(context.getFilesDir());
Process proc = null; Process proc = null;
File file = attachment.getFile(context); try (OutputStream os = new BufferedOutputStream(new FileOutputStream(logcat))) {
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
proc = pb.start(); proc = pb.start();
Helper.copy(proc.getInputStream(), os);
long size = 0;
try (BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
String line;
while ((line = br.readLine()) != null)
size += write(os, line + "\r\n");
}
db.attachment().setDownloaded(attachment.id, size);
if (!BuildConfig.DEBUG && size > MIN_ZIP_SIZE)
attachment.zip(context);
} finally { } finally {
if (proc != null) if (proc != null)
proc.destroy(); proc.destroy();
} }
*/
files.add(logcat);
attachment.zip(context, files.toArray(new File[0]));
Helper.secureDelete(logcat);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
} }

@ -3,6 +3,7 @@ level = info
writer1 = logcat writer1 = logcat
writer1.format = {tag} {message} writer1.format = {tag} {message}
writer1.level = warn
writer2 = rolling file writer2 = rolling file
writer2.file = #{tinylog.directory}/{date:yyyy-MM-dd_HH-mm-ss}.txt writer2.file = #{tinylog.directory}/{date:yyyy-MM-dd_HH-mm-ss}.txt

Loading…
Cancel
Save