mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-23 07:00:36 +00:00
Add js logs to archive
This commit is contained in:
parent
713a461415
commit
3226309bab
@ -559,7 +559,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendLogs(final String dbJson, final Callback callback) {
|
||||
public void sendLogs(final String dbJson, final String jsLogs, final Callback callback) {
|
||||
Log.d(TAG, "sendLogs");
|
||||
if (!checkAvailability()) {
|
||||
return;
|
||||
|
@ -201,7 +201,7 @@ void showFileInGraphicalShell(QWidget *parent, const QFileInfo &fileInfo)
|
||||
#endif
|
||||
}
|
||||
|
||||
void RCTStatus::sendLogs(QString dbJSON, double callbackId) {
|
||||
void RCTStatus::sendLogs(QString dbJSON, QString jsLogs, double callbackId) {
|
||||
Q_D(RCTStatus);
|
||||
|
||||
qCDebug(RCTSTATUS) << "::sendLogs call - logFilePath:" << getLogFilePath()
|
||||
@ -230,6 +230,7 @@ void RCTStatus::sendLogs(QString dbJSON, double callbackId) {
|
||||
QFile gethLogFile(d_gethLogFilePath);
|
||||
QFile logFile(getLogFilePath());
|
||||
zipWriter.addFile("db.json", dbJSON.toUtf8());
|
||||
zipWriter.addFile("js_logs.log", jsLogs.toUtf8());
|
||||
if (gethLogFile.exists()) {
|
||||
zipWriter.addFile(QFileInfo(gethLogFile).fileName(), &gethLogFile);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
Q_INVOKABLE void stopNode();
|
||||
Q_INVOKABLE void createAccount(QString password, double callbackId);
|
||||
Q_INVOKABLE void sendDataNotification(QString dataPayloadJSON, QString tokensJSON, double callbackId);
|
||||
Q_INVOKABLE void sendLogs(QString dbJSON, double callbackId);
|
||||
Q_INVOKABLE void sendLogs(QString dbJSON, QString jsLogs, double callbackId);
|
||||
Q_INVOKABLE void addPeer(QString enode, double callbackId);
|
||||
Q_INVOKABLE void recoverAccount(QString passphrase, QString password, double callbackId);
|
||||
Q_INVOKABLE void login(QString address, QString password, double callbackId);
|
||||
|
@ -229,6 +229,7 @@ RCT_EXPORT_METHOD(sendDataNotification:(NSString *)dataPayloadJSON
|
||||
#pragma mark - SendLogs method
|
||||
//////////////////////////////////////////////////////////////////// sendLogs
|
||||
RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson
|
||||
jsLogs:(NSString *)jsLogs
|
||||
callback:(RCTResponseSenderBlock)callback) {
|
||||
// TODO: Implement SendLogs for iOS
|
||||
#if DEBUG
|
||||
@ -239,35 +240,37 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson
|
||||
NSURL *rootUrl =[[fileManager
|
||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
||||
lastObject];
|
||||
|
||||
|
||||
NSURL *zipFile = [rootUrl URLByAppendingPathComponent:@"logs.zip"];
|
||||
[fileManager removeItemAtPath:zipFile.path error:nil];
|
||||
|
||||
|
||||
NSURL *logsFolderName = [rootUrl URLByAppendingPathComponent:@"logs"];
|
||||
|
||||
|
||||
if (![fileManager fileExistsAtPath:logsFolderName.path])
|
||||
[fileManager createDirectoryAtPath:logsFolderName.path withIntermediateDirectories:YES attributes:nil error:&error];
|
||||
|
||||
|
||||
NSURL *dbFile = [logsFolderName URLByAppendingPathComponent:@"db.json"];
|
||||
NSURL *jsLogsFile = [logsFolderName URLByAppendingPathComponent:@"Status.log"];
|
||||
#if DEBUG
|
||||
NSString *networkDirPath = @"ethereum/mainnet_rpc_dev";
|
||||
#else
|
||||
NSString *networkDirPath = @"ethereum/mainnet_rpc";
|
||||
#endif
|
||||
|
||||
|
||||
NSURL *networkDir = [rootUrl URLByAppendingPathComponent:networkDirPath];
|
||||
NSURL *originalGethLogsFile = [networkDir URLByAppendingPathComponent:@"geth.log"];
|
||||
NSURL *gethLogsFile = [logsFolderName URLByAppendingPathComponent:@"geth.log"];
|
||||
|
||||
|
||||
[dbJson writeToFile:dbFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
|
||||
[jsLogs writeToFile:jsLogsFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
|
||||
//NSString* gethLogs = StatusgoExportNodeLogs();
|
||||
//[gethLogs writeToFile:gethLogsFile.path atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
[fileManager copyItemAtPath:originalGethLogsFile.path toPath:gethLogsFile.path error:nil];
|
||||
|
||||
|
||||
[SSZipArchive createZipFileAtPath:zipFile.path withContentsOfDirectory:logsFolderName.path];
|
||||
[fileManager removeItemAtPath:logsFolderName.path error:nil];
|
||||
|
||||
|
||||
callback(@[zipFile.path]);
|
||||
}
|
||||
|
||||
@ -355,7 +358,7 @@ RCT_EXPORT_METHOD(verify:(NSString *)address
|
||||
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
|
||||
lastObject];
|
||||
NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"];
|
||||
|
||||
|
||||
NSString *result = StatusgoVerifyAccountPassword(absKeystoreUrl.path, address, password);
|
||||
callback(@[result]);
|
||||
}
|
||||
|
@ -7,10 +7,8 @@
|
||||
[reagent.core :as reagent]
|
||||
status-im.transport.impl.receive
|
||||
status-im.transport.impl.send
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.react-native.js-dependencies :as js-dependencies]
|
||||
[goog.object :as object]
|
||||
[status-im.utils.logging.core :as utils.logs]
|
||||
cljs.core.specs.alpha))
|
||||
|
||||
(if js/goog.DEBUG
|
||||
@ -18,7 +16,7 @@
|
||||
(aset js/console "disableYellowBox" true))
|
||||
|
||||
(defn init [app-root]
|
||||
(log/set-level! config/log-level)
|
||||
(utils.logs/init-logs)
|
||||
(error-handler/register-exception-handler!)
|
||||
(re-frame/dispatch [:init/app-started])
|
||||
(.registerComponent react/app-registry "StatusIm" #(reagent/reactify-component app-root))
|
||||
|
@ -70,8 +70,8 @@
|
||||
(defn send-data-notification [m callback]
|
||||
(native-module/send-data-notification m callback))
|
||||
|
||||
(defn send-logs [dbJson callback]
|
||||
(native-module/send-logs dbJson callback))
|
||||
(defn send-logs [dbJson js-logs callback]
|
||||
(native-module/send-logs dbJson js-logs callback))
|
||||
|
||||
(defn add-peer [enode callback]
|
||||
(native-module/add-peer enode callback))
|
||||
|
@ -49,9 +49,9 @@
|
||||
(when status
|
||||
(.sendDataNotification status data-payload tokens on-result)))
|
||||
|
||||
(defn send-logs [dbJson callback]
|
||||
(defn send-logs [dbJson js-logs callback]
|
||||
(when status
|
||||
(.sendLogs status dbJson callback)))
|
||||
(.sendLogs status dbJson js-logs callback)))
|
||||
|
||||
(defn add-peer [enode on-result]
|
||||
(when (and @node-started status)
|
||||
|
@ -4,15 +4,36 @@
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.email :as mail]))
|
||||
[status-im.utils.email :as mail]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.config :as config]))
|
||||
|
||||
(def report-email "error-reports@status.im")
|
||||
(def max-log-entries 1000)
|
||||
(def logs-queue (atom #queue[]))
|
||||
(defn add-log-entry [entry]
|
||||
(swap! logs-queue conj entry)
|
||||
(when (>= (count @logs-queue) max-log-entries)
|
||||
(swap! logs-queue pop)))
|
||||
|
||||
(defn init-logs []
|
||||
(log/set-level! config/log-level)
|
||||
(log/debug)
|
||||
(log/merge-config!
|
||||
{:output-fn (fn [& data]
|
||||
(let [res (apply log/default-output-fn data)]
|
||||
(add-log-entry res)
|
||||
res))}))
|
||||
|
||||
(defn get-js-logs []
|
||||
(clojure.string/join "\n" @logs-queue))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:logs/archive-logs
|
||||
(fn [[db-json callback-handler]]
|
||||
(status/send-logs
|
||||
db-json
|
||||
(get-js-logs)
|
||||
#(re-frame/dispatch [callback-handler %]))))
|
||||
|
||||
(fx/defn send-logs
|
||||
|
Loading…
x
Reference in New Issue
Block a user