[#3987] disable logging on status-go side if file is not writable
This commit is contained in:
parent
2c7063f96e
commit
0d0be37904
|
@ -122,11 +122,15 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
try {
|
try {
|
||||||
logFile.setReadable(true);
|
logFile.setReadable(true);
|
||||||
File parent = logFile.getParentFile();
|
File parent = logFile.getParentFile();
|
||||||
|
if (!parent.canWrite()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
parent.mkdirs();
|
parent.mkdirs();
|
||||||
}
|
}
|
||||||
logFile.createNewFile();
|
logFile.createNewFile();
|
||||||
logFile.setReadable(true);
|
logFile.setWritable(true);
|
||||||
|
Log.d(TAG, "Can write " + logFile.canWrite());
|
||||||
Uri gethLogUri = Uri.fromFile(logFile);
|
Uri gethLogUri = Uri.fromFile(logFile);
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Attach to geth.log to instabug " + gethLogUri.getPath());
|
Log.d(TAG, "Attach to geth.log to instabug " + gethLogUri.getPath());
|
||||||
|
@ -136,7 +140,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
}
|
}
|
||||||
|
|
||||||
String gethLogFilePath = logFile.getAbsolutePath();
|
String gethLogFilePath = logFile.getAbsolutePath();
|
||||||
Log.d("ExtDirLog", gethLogFilePath);
|
Log.d(TAG, gethLogFilePath);
|
||||||
|
|
||||||
return gethLogFilePath;
|
return gethLogFilePath;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -215,7 +219,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
String gethLogFilePath = prepareLogsFile();
|
String gethLogFilePath = prepareLogsFile();
|
||||||
boolean logsEnabled = (gethLogFilePath != null) && !TextUtils.isEmpty(this.logLevel);
|
boolean logsEnabled = (gethLogFilePath != null) && !TextUtils.isEmpty(this.logLevel);
|
||||||
String dataDir = root + customConfig.get("DataDir");
|
String dataDir = root + customConfig.get("DataDir");
|
||||||
jsonConfig.put("LogEnabled", logsEnabled);
|
jsonConfig.put("LogEnabled", (gethLogFilePath != null && logsEnabled));
|
||||||
jsonConfig.put("LogFile", gethLogFilePath);
|
jsonConfig.put("LogFile", gethLogFilePath);
|
||||||
jsonConfig.put("LogLevel", TextUtils.isEmpty(this.logLevel) ? "ERROR" : this.logLevel.toUpperCase());
|
jsonConfig.put("LogLevel", TextUtils.isEmpty(this.logLevel) ? "ERROR" : this.logLevel.toUpperCase());
|
||||||
jsonConfig.put("DataDir", dataDir);
|
jsonConfig.put("DataDir", dataDir);
|
||||||
|
|
Loading…
Reference in New Issue