android, ios: Pass log level from env in JSON config to Android and iOS (#2756)
- Add `LOG_LEVEL_STATUS_GO` feature flag for a differentiated log level in status-go. - Remove superfluous `DEBUG_LOGS_ENABLED` feature flag. - Enable info-level logging for Jenkins and dev builds. Signed-off-by: andytudhope <tuddy0525@gmail.com>
This commit is contained in:
parent
01d993c32e
commit
96ff13a4df
2
.env
2
.env
|
@ -1,10 +1,10 @@
|
||||||
TESTFAIRY_ENABLED=0
|
TESTFAIRY_ENABLED=0
|
||||||
NOTIFICATIONS_WIP_ENABLED=1
|
NOTIFICATIONS_WIP_ENABLED=1
|
||||||
DEBUG_LOGS_ENABLED=1
|
|
||||||
STUB_STATUS_GO=0
|
STUB_STATUS_GO=0
|
||||||
ETHEREUM_DEV_CLUSTER=1
|
ETHEREUM_DEV_CLUSTER=1
|
||||||
MAINNET_NETWORKS_ENABLED=1
|
MAINNET_NETWORKS_ENABLED=1
|
||||||
ERC20_ENABLED=1
|
ERC20_ENABLED=1
|
||||||
OFFLINE_INBOX_ENABLED=1
|
OFFLINE_INBOX_ENABLED=1
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
|
LOG_LEVEL_STATUS_GO=info
|
||||||
JSC_ENABLED=1
|
JSC_ENABLED=1
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
TESTFAIRY_ENABLED=1
|
TESTFAIRY_ENABLED=1
|
||||||
NOTIFICATIONS_WIP_ENABLED=1
|
NOTIFICATIONS_WIP_ENABLED=1
|
||||||
DEBUG_LOGS_ENABLED=1
|
|
||||||
STUB_STATUS_GO=0
|
STUB_STATUS_GO=0
|
||||||
ETHEREUM_DEV_CLUSTER=1
|
ETHEREUM_DEV_CLUSTER=1
|
||||||
MAINNET_NETWORKS_ENABLED=1
|
MAINNET_NETWORKS_ENABLED=1
|
||||||
ERC20_ENABLED=1
|
ERC20_ENABLED=1
|
||||||
OFFLINE_INBOX_ENABLED=1
|
OFFLINE_INBOX_ENABLED=1
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
|
LOG_LEVEL_STATUS_GO=info
|
||||||
JSC_ENABLED=0
|
JSC_ENABLED=0
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
TESTFAIRY_ENABLED=0
|
TESTFAIRY_ENABLED=0
|
||||||
NOTIFICATIONS_WIP_ENABLED=1
|
NOTIFICATIONS_WIP_ENABLED=1
|
||||||
DEBUG_LOGS_ENABLED=0
|
|
||||||
STUB_STATUS_GO=0
|
STUB_STATUS_GO=0
|
||||||
ETHEREUM_DEV_CLUSTER=0
|
ETHEREUM_DEV_CLUSTER=0
|
||||||
MAINNET_NETWORKS_ENABLED=0
|
MAINNET_NETWORKS_ENABLED=0
|
||||||
ERC20_ENABLED=0
|
ERC20_ENABLED=0
|
||||||
OFFLINE_INBOX_ENABLED=0
|
OFFLINE_INBOX_ENABLED=0
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
LOG_LEVEL_STATUS_GO=
|
||||||
JSC_ENABLED=0
|
JSC_ENABLED=0
|
||||||
|
|
|
@ -25,12 +25,12 @@ node ('macos1') {
|
||||||
// sh 'cp .env.jenkins .env'
|
// sh 'cp .env.jenkins .env'
|
||||||
sh 'echo TESTFAIRY_ENABLED=' + TESTFAIRY_ENABLED + '>>' + '.env'
|
sh 'echo TESTFAIRY_ENABLED=' + TESTFAIRY_ENABLED + '>>' + '.env'
|
||||||
sh 'echo NOTIFICATIONS_WIP_ENABLED=' + NOTIFICATIONS_WIP_ENABLED + '>>' + '.env'
|
sh 'echo NOTIFICATIONS_WIP_ENABLED=' + NOTIFICATIONS_WIP_ENABLED + '>>' + '.env'
|
||||||
sh 'echo DEBUG_LOGS_ENABLED=' + DEBUG_LOGS_ENABLED + '>>' + '.env'
|
|
||||||
sh 'echo STUB_STATUS_GO=' + STUB_STATUS_GO + '>>' + '.env'
|
sh 'echo STUB_STATUS_GO=' + STUB_STATUS_GO + '>>' + '.env'
|
||||||
sh 'echo ETHEREUM_DEV_CLUSTER=' + ETHEREUM_DEV_CLUSTER + '>>' + '.env'
|
sh 'echo ETHEREUM_DEV_CLUSTER=' + ETHEREUM_DEV_CLUSTER + '>>' + '.env'
|
||||||
sh 'echo MAINNET_NETWORKS_ENABLED=' + MAINNET_NETWORKS_ENABLED + '>>' + '.env'
|
sh 'echo MAINNET_NETWORKS_ENABLED=' + MAINNET_NETWORKS_ENABLED + '>>' + '.env'
|
||||||
sh 'echo ERC20_ENABLED=' + ERC20_ENABLED + '>>' + '.env'
|
sh 'echo ERC20_ENABLED=' + ERC20_ENABLED + '>>' + '.env'
|
||||||
sh 'echo LOG_LEVEL=' + LOG_LEVEL + '>>' + '.env'
|
sh 'echo LOG_LEVEL=' + LOG_LEVEL + '>>' + '.env'
|
||||||
|
sh 'echo LOG_LEVEL_STATUS_GO=' + LOG_LEVEL_STATUS_GO + '>>' + '.env'
|
||||||
sh 'echo JSC_ENABLED=' + JSC_ENABLED + '>>' + '.env'
|
sh 'echo JSC_ENABLED=' + JSC_ENABLED + '>>' + '.env'
|
||||||
sh 'echo OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env'
|
sh 'echo OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env'
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class MainApplication extends MultiDexApplication implements ReactApplica
|
||||||
jscEnabled = true;
|
jscEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusPackage statusPackage = new StatusPackage(BuildConfig.DEBUG, devCluster, jscEnabled);
|
StatusPackage statusPackage = new StatusPackage(BuildConfig.DEBUG, devCluster, jscEnabled, BuildConfig.LOG_LEVEL_STATUS_GO);
|
||||||
Function<String, String> callRPC = statusPackage.getCallRPC();
|
Function<String, String> callRPC = statusPackage.getCallRPC();
|
||||||
List<ReactPackage> packages = new ArrayList<ReactPackage>(Arrays.asList(
|
List<ReactPackage> packages = new ArrayList<ReactPackage>(Arrays.asList(
|
||||||
new MainReactPackage(),
|
new MainReactPackage(),
|
||||||
|
|
|
@ -65,10 +65,19 @@ RCTLogFunction RCTTestFairyLogFunction = ^(
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
NSURL *jsCodeLocation;
|
NSURL *jsCodeLocation;
|
||||||
|
|
||||||
/* Enable debug logs from React Native for release mode */
|
/* Set logging level from React Native */
|
||||||
NSString *debugLogsEnabled = [ReactNativeConfig envFor:@"DEBUG_LOGS_ENABLED"];
|
NSString *logLevel = [ReactNativeConfig envFor:@"LOG_LEVEL"];
|
||||||
if([debugLogsEnabled isEqualToString:@"1"]){
|
if([logLevel isEqualToString:@"error"]){
|
||||||
RCTSetLogThreshold(RCTLogLevelInfo - 1);
|
RCTSetLogThreshold(RCTLogLevelError);
|
||||||
|
}
|
||||||
|
else if([logLevel isEqualToString:@"warn"]){
|
||||||
|
RCTSetLogThreshold(RCTLogLevelWarning);
|
||||||
|
}
|
||||||
|
else if([logLevel isEqualToString:@"info"]){
|
||||||
|
RCTSetLogThreshold(RCTLogLevelInfo);
|
||||||
|
}
|
||||||
|
else if([logLevel isEqualToString:@"debug"]){
|
||||||
|
RCTSetLogThreshold(RCTLogLevelTrace);
|
||||||
RCTSetLogFunction(RCTTestFairyLogFunction);
|
RCTSetLogFunction(RCTTestFairyLogFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.CookieSyncManager;
|
import android.webkit.CookieSyncManager;
|
||||||
|
@ -39,15 +40,17 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
private ExecutorService executor = null;
|
private ExecutorService executor = null;
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private boolean devCluster;
|
private boolean devCluster;
|
||||||
|
private String logLevel;
|
||||||
private Jail jail;
|
private Jail jail;
|
||||||
|
|
||||||
StatusModule(ReactApplicationContext reactContext, boolean debug, boolean devCluster, boolean jscEnabled) {
|
StatusModule(ReactApplicationContext reactContext, boolean debug, boolean devCluster, boolean jscEnabled, String logLevel) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
if (executor == null) {
|
if (executor == null) {
|
||||||
executor = Executors.newCachedThreadPool();
|
executor = Executors.newCachedThreadPool();
|
||||||
}
|
}
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.devCluster = devCluster;
|
this.devCluster = devCluster;
|
||||||
|
this.logLevel = logLevel;
|
||||||
reactContext.addLifecycleEventListener(this);
|
reactContext.addLifecycleEventListener(this);
|
||||||
if(jscEnabled) {
|
if(jscEnabled) {
|
||||||
jail = new JSCJail(this);
|
jail = new JSCJail(this);
|
||||||
|
@ -177,9 +180,9 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
JSONObject customConfig = new JSONObject(defaultConfig);
|
JSONObject customConfig = new JSONObject(defaultConfig);
|
||||||
JSONObject jsonConfig = new JSONObject(config);
|
JSONObject jsonConfig = new JSONObject(config);
|
||||||
String gethLogFileName = "geth.log";
|
String gethLogFileName = "geth.log";
|
||||||
jsonConfig.put("LogEnabled", false);
|
jsonConfig.put("LogEnabled", !TextUtils.isEmpty(this.logLevel));
|
||||||
jsonConfig.put("LogFile", gethLogFileName);
|
jsonConfig.put("LogFile", gethLogFileName);
|
||||||
jsonConfig.put("LogLevel", "INFO");
|
jsonConfig.put("LogLevel", this.logLevel.toUpperCase());
|
||||||
jsonConfig.put("DataDir", root + customConfig.get("DataDir"));
|
jsonConfig.put("DataDir", root + customConfig.get("DataDir"));
|
||||||
jsonConfig.put("NetworkId", customConfig.get("NetworkId"));
|
jsonConfig.put("NetworkId", customConfig.get("NetworkId"));
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,11 +17,13 @@ public class StatusPackage implements ReactPackage {
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private boolean devCluster;
|
private boolean devCluster;
|
||||||
private boolean jscEnabled;
|
private boolean jscEnabled;
|
||||||
|
private String logLevel;
|
||||||
|
|
||||||
public StatusPackage (boolean debug, boolean devCluster, boolean jscEnabled) {
|
public StatusPackage (boolean debug, boolean devCluster, boolean jscEnabled, String logLevel) {
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.devCluster = devCluster;
|
this.devCluster = devCluster;
|
||||||
this.jscEnabled = jscEnabled;
|
this.jscEnabled = jscEnabled;
|
||||||
|
this.logLevel = logLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +31,7 @@ public class StatusPackage implements ReactPackage {
|
||||||
List<NativeModule> modules = new ArrayList<>();
|
List<NativeModule> modules = new ArrayList<>();
|
||||||
System.loadLibrary("statusgoraw");
|
System.loadLibrary("statusgoraw");
|
||||||
System.loadLibrary("statusgo");
|
System.loadLibrary("statusgo");
|
||||||
modules.add(new StatusModule(reactContext, this.debug, this.devCluster, this.jscEnabled));
|
modules.add(new StatusModule(reactContext, this.debug, this.devCluster, this.jscEnabled, this.logLevel));
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,7 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) {
|
||||||
NSString *upstreamURL = [configJSON valueForKeyPath:@"UpstreamConfig.URL"];
|
NSString *upstreamURL = [configJSON valueForKeyPath:@"UpstreamConfig.URL"];
|
||||||
NSString *networkDir = [rootUrl.path stringByAppendingString:dataDir];
|
NSString *networkDir = [rootUrl.path stringByAppendingString:dataDir];
|
||||||
NSString *devCluster = [ReactNativeConfig envFor:@"ETHEREUM_DEV_CLUSTER"];
|
NSString *devCluster = [ReactNativeConfig envFor:@"ETHEREUM_DEV_CLUSTER"];
|
||||||
|
NSString *logLevel = [[ReactNativeConfig envFor:@"LOG_LEVEL_STATUS_GO"] uppercaseString];
|
||||||
int dev = 0;
|
int dev = 0;
|
||||||
if([devCluster isEqualToString:@"1"]){
|
if([devCluster isEqualToString:@"1"]){
|
||||||
dev = 1;
|
dev = 1;
|
||||||
|
@ -200,9 +201,9 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) {
|
||||||
NSURL *networkDirUrl = [NSURL fileURLWithPath:networkDir];
|
NSURL *networkDirUrl = [NSURL fileURLWithPath:networkDir];
|
||||||
NSURL *logUrl = [networkDirUrl URLByAppendingPathComponent:@"geth.log"];
|
NSURL *logUrl = [networkDirUrl URLByAppendingPathComponent:@"geth.log"];
|
||||||
[resultingConfigJson setValue:newKeystoreUrl.path forKey:@"KeyStoreDir"];
|
[resultingConfigJson setValue:newKeystoreUrl.path forKey:@"KeyStoreDir"];
|
||||||
[resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKey:@"LogEnabled"];
|
[resultingConfigJson setValue:[NSNumber numberWithBool:[logLevel length] != 0] forKey:@"LogEnabled"];
|
||||||
[resultingConfigJson setValue:logUrl.path forKey:@"LogFile"];
|
[resultingConfigJson setValue:logUrl.path forKey:@"LogFile"];
|
||||||
[resultingConfigJson setValue:@"DEBUG" forKey:@"LogLevel"];
|
[resultingConfigJson setValue:logLevel forKey:@"LogLevel"];
|
||||||
|
|
||||||
if(upstreamURL != nil) {
|
if(upstreamURL != nil) {
|
||||||
[resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKeyPath:@"UpstreamConfig.Enabled"];
|
[resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKeyPath:@"UpstreamConfig.Enabled"];
|
||||||
|
|
Loading…
Reference in New Issue