diff --git a/.env b/.env index 33618ea666..9ba1e7a67f 100644 --- a/.env +++ b/.env @@ -36,3 +36,4 @@ TEST_NETWORKS_ENABLED=1 SHOW_NOT_IMPLEMENTED_FEATURES=0 ENABLE_ALERT_BANNER=0 FLAG_WALLET_CONNECT_ENABLED=1 +LOG_REQUEST_GO=1 diff --git a/.env.e2e b/.env.e2e index 9ed1b68dff..1469b07e08 100644 --- a/.env.e2e +++ b/.env.e2e @@ -40,3 +40,4 @@ DELETE_MESSAGE_UNDO_TIME_LIMIT=10000 ENABLE_ALERT_BANNER=0 FLAG_WALLET_CONNECT_ENABLED=1 MOBILE_DATA_SYNCING_TOGGLE_ENABLE=0 +LOG_REQUEST_GO=1 diff --git a/.env.jenkins b/.env.jenkins index 33f1644366..5cd528cf52 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -37,3 +37,4 @@ FAST_CREATE_COMMUNITY_ENABLED=1 TEST_NETWORKS_ENABLED=1 ENABLE_ALERT_BANNER=1 FLAG_WALLET_CONNECT_ENABLED=1 +LOG_REQUEST_GO=1 diff --git a/.env.nightly b/.env.nightly index 82fac88963..a627f0a1b0 100644 --- a/.env.nightly +++ b/.env.nightly @@ -24,3 +24,4 @@ FAST_CREATE_COMMUNITY_ENABLED=0 TEST_NETWORKS_ENABLED=0 ENABLE_ALERT_BANNER=1 FLAG_WALLET_CONNECT_ENABLED=1 +LOG_REQUEST_GO=0 diff --git a/.env.release b/.env.release index ca78f8d583..1c6ada023b 100644 --- a/.env.release +++ b/.env.release @@ -21,3 +21,4 @@ FAST_CREATE_COMMUNITY_ENABLED=0 TEST_NETWORKS_ENABLED=0 STATUS_PROXY_STAGE_NAME=prod FLAG_WALLET_CONNECT_ENABLED=1 +LOG_REQUEST_GO=0 diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/LogManager.kt b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/LogManager.kt index f5481a13ee..1bf10fdf94 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/LogManager.kt +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/LogManager.kt @@ -25,13 +25,18 @@ class LogManager(private val reactContext: ReactApplicationContext) : ReactConte override fun getName() = "LogManager" - private fun getLogsFile(): File { + private fun getRequestLogFile(): File { + val pubDirectory = utils.getPublicStorageDirectory() + return File(pubDirectory, requestsLogFileName) + } + + private fun getGethLogFile(): File { val pubDirectory = utils.getPublicStorageDirectory() return File(pubDirectory, gethLogFileName) } fun prepareLogsFile(context: Context): File? { - val logFile = utils.getLogsFile() + val logFile = getGethLogFile() try { logFile.setReadable(true) @@ -149,7 +154,8 @@ class LogManager(private val reactContext: ReactApplicationContext) : ReactConte val zipFile = File(logsTempDir, logsZipFileName) val statusLogFile = File(logsTempDir, statusLogFileName) - val gethLogFile = getLogsFile() + val gethLogFile = getGethLogFile() + val requestLogFile = getRequestLogFile() try { if (zipFile.exists() || zipFile.createNewFile()) { @@ -165,7 +171,11 @@ class LogManager(private val reactContext: ReactApplicationContext) : ReactConte dumpAdbLogsTo(FileOutputStream(statusLogFile)) val errorList = Stack() - val zipped = zip(arrayOf(dbFile, gethLogFile, statusLogFile), zipFile, errorList) + val filesToZip = mutableListOf(dbFile, gethLogFile, statusLogFile) + if (requestLogFile.exists()) { + filesToZip.add(requestLogFile) + } + val zipped = zip(filesToZip.toTypedArray(), zipFile, errorList) if (zipped && zipFile.exists()) { zipFile.setReadable(true, false) val extUri = FileProvider.getUriForFile(context, "${context.packageName}.provider", zipFile) @@ -186,12 +196,14 @@ class LogManager(private val reactContext: ReactApplicationContext) : ReactConte } @ReactMethod - fun initLogging(enabled: Boolean, mobileSystem: Boolean, logLevel: String, callback: Callback) { + fun initLogging(enabled: Boolean, mobileSystem: Boolean, logLevel: String, logRequestGo: Boolean, callback: Callback) { val jsonConfig = JSONObject().apply { put("Enabled", enabled) put("MobileSystem", mobileSystem) put("Level", logLevel) - put("File", getLogsFile().absolutePath) + put("File", getGethLogFile().absolutePath) + put("LogRequestGo", logRequestGo) + put("LogRequestFile", getRequestLogFile().absolutePath) } val config = jsonConfig.toString() utils.executeRunnableStatusGoMethod({ Statusgo.initLogging(config) }, callback) @@ -206,6 +218,7 @@ class LogManager(private val reactContext: ReactApplicationContext) : ReactConte private const val TAG = "LogManager" private const val gethLogFileName = "geth.log" private const val statusLogFileName = "Status.log" + private const val requestsLogFileName = "requests.log" private const val logsZipFileName = "Status-debug-logs.zip" } } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/Utils.kt b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/Utils.kt index 0401424312..5333266fb4 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/Utils.kt +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/Utils.kt @@ -17,7 +17,6 @@ import statusgo.Statusgo class Utils(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { companion object { - private const val gethLogFileName = "geth.log" private const val TAG = "Utils" } @@ -40,11 +39,6 @@ class Utils(private val reactContext: ReactApplicationContext) : ReactContextBas return reactContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) } - fun getLogsFile(): File { - val pubDirectory = getPublicStorageDirectory() - return File(pubDirectory, gethLogFileName) - } - fun getKeyUID(json: String): String { val jsonObj = JSONObject(json) return jsonObj.getString("key-uid") diff --git a/modules/react-native-status/ios/RCTStatus/LogManager.m b/modules/react-native-status/ios/RCTStatus/LogManager.m index 1a5740b571..028f72c3c5 100644 --- a/modules/react-native-status/ios/RCTStatus/LogManager.m +++ b/modules/react-native-status/ios/RCTStatus/LogManager.m @@ -57,6 +57,8 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson NSURL *mainGethLogsFile = [rootUrl URLByAppendingPathComponent:@"geth.log"]; NSURL *mainLogsFile = [logsFolderName URLByAppendingPathComponent:@"geth.log"]; + NSURL *requestsLogFile = [rootUrl URLByAppendingPathComponent:@"requests.log"]; + [dbJson writeToFile:dbFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil]; [jsLogs writeToFile:jsLogsFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil]; @@ -65,6 +67,10 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson [fileManager copyItemAtPath:originalGethLogsFile.path toPath:gethLogsFile.path error:nil]; [fileManager copyItemAtPath:goerliGethLogsFile.path toPath:goerliLogsFile.path error:nil]; [fileManager copyItemAtPath:mainGethLogsFile.path toPath:mainLogsFile.path error:nil]; + + if ([fileManager fileExistsAtPath:requestsLogFile.path]) { + [fileManager copyItemAtPath:requestsLogFile.path toPath:[logsFolderName URLByAppendingPathComponent:@"requests.log"].path error:nil]; + } [SSZipArchive createZipFileAtPath:zipFile.path withContentsOfDirectory:logsFolderName.path]; [fileManager removeItemAtPath:logsFolderName.path error:nil]; @@ -75,17 +81,20 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson RCT_EXPORT_METHOD(initLogging:(BOOL)enabled mobileSystem:(BOOL)mobileSystem logLevel:(NSString *)logLevel + logRequestGo:(BOOL)logRequestGo callback:(RCTResponseSenderBlock)callback) { NSString *logDirectory = [self logFileDirectory]; NSString *logFilePath = [logDirectory stringByAppendingPathComponent:@"geth.log"]; + NSString *logRequestFilePath = [logDirectory stringByAppendingPathComponent:@"requests.log"]; NSMutableDictionary *jsonConfig = [NSMutableDictionary dictionary]; jsonConfig[@"Enabled"] = @(enabled); jsonConfig[@"MobileSystem"] = @(mobileSystem); jsonConfig[@"Level"] = logLevel; jsonConfig[@"File"] = logFilePath; - + jsonConfig[@"LogRequestGo"] = @(logRequestGo); + jsonConfig[@"LogRequestFile"] = logRequestFilePath; NSError *error = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonConfig options:0 error:&error]; diff --git a/src/native_module/core.cljs b/src/native_module/core.cljs index 4efca427cb..52ac713b8d 100644 --- a/src/native_module/core.cljs +++ b/src/native_module/core.cljs @@ -531,8 +531,8 @@ (.logFileDirectory ^js (log-manager))) (defn init-status-go-logging - [{:keys [enable? mobile-system? log-level callback]}] - (.initLogging ^js (log-manager) enable? mobile-system? log-level callback)) + [{:keys [enable? mobile-system? log-level log-request-go? callback]}] + (.initLogging ^js (log-manager) enable? mobile-system? log-level log-request-go? callback)) (defn get-random-mnemonic [callback] diff --git a/src/status_im/common/log.cljs b/src/status_im/common/log.cljs index 109cfc9c7b..56609abc78 100644 --- a/src/status_im/common/log.cljs +++ b/src/status_im/common/log.cljs @@ -4,6 +4,7 @@ [clojure.string :as string] [native-module.core :as native-module] [re-frame.core :as re-frame] + [status-im.config :as config] [taoensso.timbre :as log] [utils.transforms :as transforms])) @@ -24,10 +25,11 @@ (let [{:keys [error]} (transforms/json->clj res)] (when-not (string/blank? error) (log/error "init statusgo logging failed" error)))) - logging-params {:enable? true - :mobile-system? false - :log-level level - :callback handle-error}] + logging-params {:enable? true + :mobile-system? false + :log-level level + :log-request-go? config/log-request-go + :callback handle-error}] (log/merge-config! {:ns-filter {:allow #{"*"} :deny #{"taoensso.sente"}}}) (if (string/blank? level) (native-module/init-status-go-logging (merge logging-params {:log-level "WARN"})) diff --git a/src/status_im/config.cljs b/src/status_im/config.cljs index ce66fd30b0..98a632fc8c 100644 --- a/src/status_im/config.cljs +++ b/src/status_im/config.cljs @@ -76,6 +76,7 @@ ;; CONFIG VALUES (def log-level (string/upper-case (get-config :LOG_LEVEL ""))) +(def log-request-go (enabled? (get-config :LOG_REQUEST_GO "0"))) (def fleet (get-config :FLEET "")) (def apn-topic (get-config :APN_TOPIC "im.status.ethereum")) (def default-network (get-config :DEFAULT_NETWORK "goerli_rpc")) diff --git a/src/tests/test_utils.cljs b/src/tests/test_utils.cljs index 2ab9f00c80..069e492276 100644 --- a/src/tests/test_utils.cljs +++ b/src/tests/test_utils.cljs @@ -115,12 +115,13 @@ {:logFileDirectory (fn [] (str test-dir "/log")) :initLogging - (fn [enabled mobile-system log-level callback] + (fn [enabled mobile-system log-level log-request-go? callback] (callback (.initLogging native-status - (types/clj->json {:Enabled enabled - :MobileSystem mobile-system - :Level log-level - :File (str test-dir "/geth.log")}))))})) + (types/clj->json {:Enabled enabled + :MobileSystem mobile-system + :Level log-level + :LogRequestGo log-request-go? + :LogRequestFile (str test-dir "/request.log")}))))})) (def network (clj->js diff --git a/status-go-version.json b/status-go-version.json index 8cb3fd2142..bdf6648287 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.186.0", - "commit-sha1": "b866640dc56471846f530e907d50a1df6df13ae0", - "src-sha256": "0sw8z4f4f87k01qnpp8sk7sam4bkk77nn7pd5iggqchbmpzr6638" + "version": "f859b58c3896523b2fb9a09b3e5c1cedb04f959b", + "commit-sha1": "f859b58c3896523b2fb9a09b3e5c1cedb04f959b", + "src-sha256": "009nd47aajng5k7wrcqv5zvvzniaswqi706fpkbbjhqziympi1s1" }