diff --git a/.env b/.env index 0301af62a4..6c8e5355d8 100644 --- a/.env +++ b/.env @@ -1,10 +1,10 @@ TESTFAIRY_ENABLED=0 NOTIFICATIONS_WIP_ENABLED=1 -DEBUG_LOGS_ENABLED=1 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_NETWORKS_ENABLED=1 ERC20_ENABLED=1 OFFLINE_INBOX_ENABLED=1 LOG_LEVEL=debug +LOG_LEVEL_STATUS_GO=info JSC_ENABLED=1 diff --git a/.env.jenkins b/.env.jenkins index 74f94a0158..ebc9069546 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -1,10 +1,10 @@ TESTFAIRY_ENABLED=1 NOTIFICATIONS_WIP_ENABLED=1 -DEBUG_LOGS_ENABLED=1 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_NETWORKS_ENABLED=1 ERC20_ENABLED=1 OFFLINE_INBOX_ENABLED=1 LOG_LEVEL=debug +LOG_LEVEL_STATUS_GO=info JSC_ENABLED=0 diff --git a/.env.prod b/.env.prod index 005bdf1f75..6f717ddd0e 100644 --- a/.env.prod +++ b/.env.prod @@ -1,10 +1,10 @@ TESTFAIRY_ENABLED=0 NOTIFICATIONS_WIP_ENABLED=1 -DEBUG_LOGS_ENABLED=0 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=0 MAINNET_NETWORKS_ENABLED=0 ERC20_ENABLED=0 OFFLINE_INBOX_ENABLED=0 LOG_LEVEL=info +LOG_LEVEL_STATUS_GO= JSC_ENABLED=0 diff --git a/Jenkinsfile.parameters b/Jenkinsfile.parameters index d618843dff..dca4c1e3f9 100644 --- a/Jenkinsfile.parameters +++ b/Jenkinsfile.parameters @@ -25,12 +25,12 @@ node ('macos1') { // sh 'cp .env.jenkins .env' sh 'echo TESTFAIRY_ENABLED=' + TESTFAIRY_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 ETHEREUM_DEV_CLUSTER=' + ETHEREUM_DEV_CLUSTER + '>>' + '.env' sh 'echo MAINNET_NETWORKS_ENABLED=' + MAINNET_NETWORKS_ENABLED + '>>' + '.env' sh 'echo ERC20_ENABLED=' + ERC20_ENABLED + '>>' + '.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 OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env' diff --git a/android/app/src/main/java/im/status/ethereum/MainApplication.java b/android/app/src/main/java/im/status/ethereum/MainApplication.java index 85df040481..c8d19d14d7 100644 --- a/android/app/src/main/java/im/status/ethereum/MainApplication.java +++ b/android/app/src/main/java/im/status/ethereum/MainApplication.java @@ -55,7 +55,7 @@ public class MainApplication extends MultiDexApplication implements ReactApplica jscEnabled = true; } - StatusPackage statusPackage = new StatusPackage(BuildConfig.DEBUG, devCluster, jscEnabled); + StatusPackage statusPackage = new StatusPackage(BuildConfig.DEBUG, devCluster, jscEnabled, BuildConfig.LOG_LEVEL_STATUS_GO); Function callRPC = statusPackage.getCallRPC(); List packages = new ArrayList(Arrays.asList( new MainReactPackage(), diff --git a/ios/StatusIm/AppDelegate.m b/ios/StatusIm/AppDelegate.m index fba1d06c87..88d2fc054a 100644 --- a/ios/StatusIm/AppDelegate.m +++ b/ios/StatusIm/AppDelegate.m @@ -65,10 +65,19 @@ RCTLogFunction RCTTestFairyLogFunction = ^( signal(SIGPIPE, SIG_IGN); NSURL *jsCodeLocation; - /* Enable debug logs from React Native for release mode */ - NSString *debugLogsEnabled = [ReactNativeConfig envFor:@"DEBUG_LOGS_ENABLED"]; - if([debugLogsEnabled isEqualToString:@"1"]){ - RCTSetLogThreshold(RCTLogLevelInfo - 1); + /* Set logging level from React Native */ + NSString *logLevel = [ReactNativeConfig envFor:@"LOG_LEVEL"]; + if([logLevel isEqualToString:@"error"]){ + 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); } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index d937498286..4d1b04516b 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.net.Uri; import android.os.*; import android.view.WindowManager; +import android.text.TextUtils; import android.util.Log; import android.webkit.CookieManager; import android.webkit.CookieSyncManager; @@ -39,15 +40,17 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL private ExecutorService executor = null; private boolean debug; private boolean devCluster; + private String logLevel; 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); if (executor == null) { executor = Executors.newCachedThreadPool(); } this.debug = debug; this.devCluster = devCluster; + this.logLevel = logLevel; reactContext.addLifecycleEventListener(this); if(jscEnabled) { jail = new JSCJail(this); @@ -177,9 +180,9 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL JSONObject customConfig = new JSONObject(defaultConfig); JSONObject jsonConfig = new JSONObject(config); String gethLogFileName = "geth.log"; - jsonConfig.put("LogEnabled", false); + jsonConfig.put("LogEnabled", !TextUtils.isEmpty(this.logLevel)); jsonConfig.put("LogFile", gethLogFileName); - jsonConfig.put("LogLevel", "INFO"); + jsonConfig.put("LogLevel", this.logLevel.toUpperCase()); jsonConfig.put("DataDir", root + customConfig.get("DataDir")); jsonConfig.put("NetworkId", customConfig.get("NetworkId")); try { diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java index 6fe7bcff7d..2db6a68bbd 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java @@ -17,11 +17,13 @@ public class StatusPackage implements ReactPackage { private boolean debug; private boolean devCluster; 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.devCluster = devCluster; this.jscEnabled = jscEnabled; + this.logLevel = logLevel; } @Override @@ -29,7 +31,7 @@ public class StatusPackage implements ReactPackage { List modules = new ArrayList<>(); System.loadLibrary("statusgoraw"); 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; } diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index 48768902d6..fc81055883 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -189,6 +189,7 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) { NSString *upstreamURL = [configJSON valueForKeyPath:@"UpstreamConfig.URL"]; NSString *networkDir = [rootUrl.path stringByAppendingString:dataDir]; NSString *devCluster = [ReactNativeConfig envFor:@"ETHEREUM_DEV_CLUSTER"]; + NSString *logLevel = [[ReactNativeConfig envFor:@"LOG_LEVEL_STATUS_GO"] uppercaseString]; int dev = 0; if([devCluster isEqualToString:@"1"]){ dev = 1; @@ -200,9 +201,9 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) { NSURL *networkDirUrl = [NSURL fileURLWithPath:networkDir]; NSURL *logUrl = [networkDirUrl URLByAppendingPathComponent:@"geth.log"]; [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:@"DEBUG" forKey:@"LogLevel"]; + [resultingConfigJson setValue:logLevel forKey:@"LogLevel"]; if(upstreamURL != nil) { [resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKeyPath:@"UpstreamConfig.Enabled"];