mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-12 01:34:31 +00:00
attach geth.log to Instabug reports
This commit is contained in:
parent
48709aced3
commit
3bc19e69b1
@ -14,5 +14,6 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.facebook.react:react-native:+'
|
compile 'com.facebook.react:react-native:+'
|
||||||
|
compile 'com.instabug.library:instabug:3+'
|
||||||
compile(group: 'status-im', name: 'status-go', version: '0.9.8-g311f2b8', ext: 'aar')
|
compile(group: 'status-im', name: 'status-go', version: '0.9.8-g311f2b8', ext: 'aar')
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package im.status.ethereum.module;
|
package im.status.ethereum.module;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -25,6 +26,7 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import com.instabug.library.Instabug;
|
||||||
|
|
||||||
class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventListener, ConnectorHandler {
|
class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventListener, ConnectorHandler {
|
||||||
|
|
||||||
@ -125,11 +127,9 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
try {
|
try {
|
||||||
final String chaindDataFolderPath = dataFolder + "/StatusIM/lightchaindata";
|
final String chaindDataFolderPath = dataFolder + "/StatusIM/lightchaindata";
|
||||||
final File lightChainFolder = new File(chaindDataFolderPath);
|
final File lightChainFolder = new File(chaindDataFolderPath);
|
||||||
if (lightChainFolder.isDirectory())
|
if (lightChainFolder.isDirectory()) {
|
||||||
{
|
|
||||||
String[] children = lightChainFolder.list();
|
String[] children = lightChainFolder.list();
|
||||||
for (int i = 0; i < children.length; i++)
|
for (int i = 0; i < children.length; i++) {
|
||||||
{
|
|
||||||
new File(lightChainFolder, children[i]).delete();
|
new File(lightChainFolder, children[i]).delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,9 +144,33 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
String defaultConfig = Statusgo.GenerateConfig(dataFolder, 3);
|
String defaultConfig = Statusgo.GenerateConfig(dataFolder, 3);
|
||||||
try {
|
try {
|
||||||
JSONObject jsonConfig = new JSONObject(defaultConfig);
|
JSONObject jsonConfig = new JSONObject(defaultConfig);
|
||||||
jsonConfig.put("LogEnabled", this.debug);
|
String gethLogFileName = "geth.log";
|
||||||
jsonConfig.put("LogFile", "geth.log");
|
jsonConfig.put("LogEnabled", true);
|
||||||
|
jsonConfig.put("LogFile", gethLogFileName);
|
||||||
jsonConfig.put("LogLevel", "DEBUG");
|
jsonConfig.put("LogLevel", "DEBUG");
|
||||||
|
String gethLogPath = dataFolder + "/" + gethLogFileName;
|
||||||
|
File logFile = new File(gethLogPath);
|
||||||
|
if (logFile.exists()) {
|
||||||
|
logFile.delete();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
logFile.setReadable(true);
|
||||||
|
File parent = logFile.getParentFile();
|
||||||
|
if (!parent.exists()) {
|
||||||
|
parent.mkdirs();
|
||||||
|
}
|
||||||
|
logFile.createNewFile();
|
||||||
|
logFile.setReadable(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.d(TAG, "Can't create geth.log file!");
|
||||||
|
}
|
||||||
|
Uri gethLogUri = Uri.fromFile(logFile);
|
||||||
|
try {
|
||||||
|
Log.d(TAG, "Attach to geth.log to instabug " + gethLogUri.getPath());
|
||||||
|
Instabug.setFileAttachment(gethLogUri, gethLogFileName);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Log.d(TAG, "Instabug is not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
config = jsonConfig.toString();
|
config = jsonConfig.toString();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -2,6 +2,48 @@
|
|||||||
#import "React/RCTBridge.h"
|
#import "React/RCTBridge.h"
|
||||||
#import "React/RCTEventDispatcher.h"
|
#import "React/RCTEventDispatcher.h"
|
||||||
#import <Statusgo/Statusgo.h>
|
#import <Statusgo/Statusgo.h>
|
||||||
|
@import Instabug;
|
||||||
|
|
||||||
|
@interface NSDictionary (BVJSONString)
|
||||||
|
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSDictionary (BVJSONString)
|
||||||
|
|
||||||
|
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint {
|
||||||
|
NSError *error;
|
||||||
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
|
||||||
|
options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
|
||||||
|
error:&error];
|
||||||
|
|
||||||
|
if (! jsonData) {
|
||||||
|
NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription);
|
||||||
|
return @"{}";
|
||||||
|
} else {
|
||||||
|
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSArray (BVJSONString)
|
||||||
|
- (NSString *)bv_jsonStringWithPrettyPrint:(BOOL)prettyPrint;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSArray (BVJSONString)
|
||||||
|
-(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint {
|
||||||
|
NSError *error;
|
||||||
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
|
||||||
|
options:(NSJSONWritingOptions) (prettyPrint ? NSJSONWritingPrettyPrinted : 0)
|
||||||
|
error:&error];
|
||||||
|
|
||||||
|
if (! jsonData) {
|
||||||
|
NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription);
|
||||||
|
return @"[]";
|
||||||
|
} else {
|
||||||
|
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
static bool isStatusInitialized;
|
static bool isStatusInitialized;
|
||||||
static RCTBridge *bridge;
|
static RCTBridge *bridge;
|
||||||
@ -161,10 +203,33 @@ RCT_EXPORT_METHOD(startNode:(RCTResponseSenderBlock)onResultCallback) {
|
|||||||
}else
|
}else
|
||||||
NSLog(@"folderName: %@", folderName);
|
NSLog(@"folderName: %@", folderName);
|
||||||
|
|
||||||
|
char *configChars = GenerateConfig([folderName.path UTF8String], 3);
|
||||||
|
NSString *config = [NSString stringWithUTF8String: configChars];
|
||||||
|
NSData *configData = [config dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
NSDictionary *resultingConfigJson = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:nil];
|
||||||
|
[resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKey:@"LogEnabled"];
|
||||||
|
[resultingConfigJson setValue:@"geth.log" forKey:@"LogFile"];
|
||||||
|
[resultingConfigJson setValue:@"DEBUG" forKey:@"LogLevel"];
|
||||||
|
NSString *resultingConfig = [resultingConfigJson bv_jsonStringWithPrettyPrint:NO];
|
||||||
|
NSURL *logUrl = [folderName URLByAppendingPathComponent:@"geth.log"];
|
||||||
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
|
if([[NSFileManager defaultManager] fileExistsAtPath:logUrl.path]) {
|
||||||
|
[manager removeItemAtPath:logUrl.path error:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(![manager fileExistsAtPath:folderName.path]) {
|
||||||
|
[manager createDirectoryAtPath:folderName.path withIntermediateDirectories:YES attributes:nil error:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||||
|
[dict setObject:[NSNumber numberWithInt:511] forKey:NSFilePosixPermissions];
|
||||||
|
[manager createFileAtPath:logUrl.path contents:nil attributes:dict];
|
||||||
|
#ifndef DEBUG
|
||||||
|
[Instabug addFileAttachmentWithURL:[folderName URLByAppendingPathComponent:@"geth.log"]];
|
||||||
|
#endif
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
||||||
^(void) {
|
^(void) {
|
||||||
char *config = GenerateConfig([folderName.path UTF8String], 3);
|
StartNode((char *) [resultingConfig UTF8String]);
|
||||||
StartNode(config);
|
|
||||||
});
|
});
|
||||||
onResultCallback(@[[NSNull null]]);
|
onResultCallback(@[[NSNull null]]);
|
||||||
//Screen lock notifications
|
//Screen lock notifications
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
206C9F3A1D474E910063E3E6 /* libRCTStatus.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTStatus.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
206C9F3A1D474E910063E3E6 /* libRCTStatus.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTStatus.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
206C9F3D1D474E910063E3E6 /* RCTStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTStatus.h; sourceTree = "<group>"; };
|
206C9F3D1D474E910063E3E6 /* RCTStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTStatus.h; sourceTree = "<group>"; };
|
||||||
206C9F3F1D474E910063E3E6 /* RCTStatus.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTStatus.m; sourceTree = "<group>"; };
|
206C9F3F1D474E910063E3E6 /* RCTStatus.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTStatus.m; sourceTree = "<group>"; };
|
||||||
|
9E3F8AF21ED2CCBD0016D874 /* Instabug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Instabug.framework; path = ../../../../ios/Pods/Instabug/Instabug.framework; sourceTree = "<group>"; };
|
||||||
CE4E31B01D86951A0033ED64 /* Statusgo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Statusgo.framework; sourceTree = "<group>"; };
|
CE4E31B01D86951A0033ED64 /* Statusgo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Statusgo.framework; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@ -51,6 +52,7 @@
|
|||||||
CE4E31B01D86951A0033ED64 /* Statusgo.framework */,
|
CE4E31B01D86951A0033ED64 /* Statusgo.framework */,
|
||||||
206C9F3C1D474E910063E3E6 /* Status */,
|
206C9F3C1D474E910063E3E6 /* Status */,
|
||||||
206C9F3B1D474E910063E3E6 /* Products */,
|
206C9F3B1D474E910063E3E6 /* Products */,
|
||||||
|
9E3F8AF11ED2CCBD0016D874 /* Frameworks */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@ -71,6 +73,14 @@
|
|||||||
name = Status;
|
name = Status;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
9E3F8AF11ED2CCBD0016D874 /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9E3F8AF21ED2CCBD0016D874 /* Instabug.framework */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@ -226,6 +236,7 @@
|
|||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)",
|
"$(PROJECT_DIR)",
|
||||||
|
"$(PROJECT_DIR)/../../../../ios/Pods/Instabug",
|
||||||
);
|
);
|
||||||
FRAMEWORK_VERSION = A;
|
FRAMEWORK_VERSION = A;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
@ -253,6 +264,7 @@
|
|||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)",
|
"$(PROJECT_DIR)",
|
||||||
|
"$(PROJECT_DIR)/../../../../ios/Pods/Instabug",
|
||||||
);
|
);
|
||||||
FRAMEWORK_VERSION = A;
|
FRAMEWORK_VERSION = A;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user