[feature #5527] allow user to change status-go loglevel in settings
This commit is contained in:
parent
aa949c64e3
commit
8d053b4389
|
@ -53,7 +53,7 @@ public class MainApplication extends MultiDexApplication implements ReactApplica
|
||||||
webViewDebugEnabled = true;
|
webViewDebugEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusPackage statusPackage = new StatusPackage(BuildConfig.DEBUG, devCluster, BuildConfig.LOG_LEVEL_STATUS_GO);
|
StatusPackage statusPackage = new StatusPackage(BuildConfig.DEBUG, devCluster);
|
||||||
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(),
|
||||||
|
|
|
@ -47,17 +47,15 @@ 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 ReactApplicationContext reactContext;
|
private ReactApplicationContext reactContext;
|
||||||
|
|
||||||
StatusModule(ReactApplicationContext reactContext, boolean debug, boolean devCluster, String logLevel) {
|
StatusModule(ReactApplicationContext reactContext, boolean debug, boolean devCluster) {
|
||||||
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;
|
|
||||||
this.reactContext = reactContext;
|
this.reactContext = reactContext;
|
||||||
reactContext.addLifecycleEventListener(this);
|
reactContext.addLifecycleEventListener(this);
|
||||||
}
|
}
|
||||||
|
@ -153,63 +151,59 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConfig(final String dataDir, final int networkId, final String keystoreDir, final String fleet, final Object upstreamConfig) throws JSONException {
|
private String generateConfig(final JSONObject defaultConfig, final String root, final String keystoreDir, final String fleet) throws JSONException {
|
||||||
|
// retrieve parameters from app config, that will be applied onto the Go-side config later on
|
||||||
|
final String dataDir = root + defaultConfig.get("DataDir");
|
||||||
|
final int networkId = defaultConfig.getInt("NetworkId");
|
||||||
|
final Object upstreamConfig = defaultConfig.opt("UpstreamConfig");
|
||||||
|
final Boolean logEnabled = defaultConfig.getBoolean("LogEnabled");
|
||||||
|
final String logLevel = defaultConfig.optString("LogLevel", "ERROR");
|
||||||
|
|
||||||
JSONObject jsonConfig = new JSONObject(
|
// retrieve config from Go side, in order to use as the basis of the config
|
||||||
Statusgo.GenerateConfig(dataDir, fleet, networkId));
|
JSONObject jsonConfig = new JSONObject(
|
||||||
|
Statusgo.GenerateConfig(dataDir, fleet, networkId));
|
||||||
|
|
||||||
jsonConfig.put("NetworkId", networkId);
|
jsonConfig.put("NetworkId", networkId);
|
||||||
jsonConfig.put("DataDir", dataDir);
|
jsonConfig.put("DataDir", dataDir);
|
||||||
jsonConfig.put("KeyStoreDir", keystoreDir);
|
jsonConfig.put("KeyStoreDir", keystoreDir);
|
||||||
|
|
||||||
if (upstreamConfig != null) {
|
if (upstreamConfig != null) {
|
||||||
Log.d(TAG, "UpstreamConfig is not null");
|
Log.d(TAG, "UpstreamConfig is not null");
|
||||||
jsonConfig.put("UpstreamConfig", upstreamConfig);
|
jsonConfig.put("UpstreamConfig", upstreamConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String gethLogFilePath = TextUtils.isEmpty(this.logLevel) ? null : prepareLogsFile();
|
final String gethLogFilePath = logEnabled ? prepareLogsFile() : null;
|
||||||
final boolean logsEnabled = (gethLogFilePath != null);
|
jsonConfig.put("LogEnabled", logEnabled);
|
||||||
|
jsonConfig.put("LogFile", gethLogFilePath);
|
||||||
|
jsonConfig.put("LogLevel", TextUtils.isEmpty(logLevel) ? "ERROR" : logLevel);
|
||||||
|
|
||||||
jsonConfig.put("LogEnabled", logsEnabled);
|
// Setting up whisper config
|
||||||
jsonConfig.put("LogFile", gethLogFilePath);
|
JSONObject whisperConfig = jsonConfig.optJSONObject("WhisperConfig");
|
||||||
jsonConfig.put("LogLevel", TextUtils.isEmpty(this.logLevel) ? "ERROR" : this.logLevel.toUpperCase());
|
if (whisperConfig == null) {
|
||||||
|
whisperConfig = new JSONObject();
|
||||||
|
}
|
||||||
|
whisperConfig.put("LightClient", true);
|
||||||
|
jsonConfig.put("WhisperConfig", whisperConfig);
|
||||||
|
|
||||||
|
// Setting up cluster config
|
||||||
|
JSONObject clusterConfig = jsonConfig.optJSONObject("ClusterConfig");
|
||||||
|
if (clusterConfig != null) {
|
||||||
|
Log.d(TAG, "ClusterConfig is not null");
|
||||||
|
clusterConfig.put("Fleet", fleet);
|
||||||
|
jsonConfig.put("ClusterConfig", clusterConfig);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "ClusterConfig: Cannot find ClusterConfig: doesn't exist or not a JSON object");
|
||||||
|
Log.w(TAG, "ClusterConfig: Fleet will be set to defaults");
|
||||||
|
}
|
||||||
|
|
||||||
// Setting up whisper config
|
return jsonConfig.toString();
|
||||||
JSONObject whisperConfig = jsonConfig.optJSONObject("WhisperConfig");
|
|
||||||
if (whisperConfig == null) {
|
|
||||||
whisperConfig = new JSONObject();
|
|
||||||
}
|
|
||||||
whisperConfig.put("LightClient", true);
|
|
||||||
jsonConfig.put("WhisperConfig", whisperConfig);
|
|
||||||
|
|
||||||
|
|
||||||
// Setting up cluster config
|
|
||||||
JSONObject clusterConfig = jsonConfig.optJSONObject("ClusterConfig");
|
|
||||||
if (clusterConfig != null) {
|
|
||||||
Log.d(TAG, "ClusterConfig is not null");
|
|
||||||
clusterConfig.put("Fleet", fleet);
|
|
||||||
jsonConfig.put("ClusterConfig", clusterConfig);
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "ClusterConfig: Cannot find ClusterConfig: doesn't exist or not a JSON object");
|
|
||||||
Log.w(TAG, "ClusterConfig: Fleet will be set to defaults");
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonConfig.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String generateConfigFromDefaultConfig(final String root, final String keystoreDir, final String fleet, final String defaultConfig) {
|
private String generateConfigFromDefaultConfig(final String root, final String keystoreDir, final String fleet, final String defaultConfig) {
|
||||||
try {
|
try {
|
||||||
JSONObject customConfig = new JSONObject(defaultConfig);
|
JSONObject customConfig = new JSONObject(defaultConfig);
|
||||||
|
|
||||||
// parameters from config
|
return generateConfig(customConfig, root, keystoreDir, fleet);
|
||||||
final String dataDir = root + customConfig.get("DataDir");
|
|
||||||
final int networkId = customConfig.getInt("NetworkId");
|
|
||||||
final Object upstreamConfig = customConfig.opt("UpstreamConfig");
|
|
||||||
|
|
||||||
return generateConfig(dataDir, networkId, keystoreDir, fleet, upstreamConfig);
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.d(TAG, "Something went wrong " + e.getMessage());
|
Log.d(TAG, "Something went wrong " + e.getMessage());
|
||||||
Log.d(TAG, "Default configuration will be used: ropsten, beta fleet");
|
Log.d(TAG, "Default configuration will be used: ropsten, beta fleet");
|
||||||
|
|
|
@ -16,12 +16,10 @@ public class StatusPackage implements ReactPackage {
|
||||||
|
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private boolean devCluster;
|
private boolean devCluster;
|
||||||
private String logLevel;
|
|
||||||
|
|
||||||
public StatusPackage (boolean debug, boolean devCluster, String logLevel) {
|
public StatusPackage (boolean debug, boolean devCluster) {
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.devCluster = devCluster;
|
this.devCluster = devCluster;
|
||||||
this.logLevel = logLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +27,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.logLevel));
|
modules.add(new StatusModule(reactContext, this.debug, this.devCluster));
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,10 +108,8 @@ void RCTStatus::startNode(QString configString, QString fleet) {
|
||||||
qDebug() << " RCTStatus::startNode GenerateConfig configString: " << jsonDoc.toVariant().toMap();
|
qDebug() << " RCTStatus::startNode GenerateConfig configString: " << jsonDoc.toVariant().toMap();
|
||||||
QVariantMap generatedConfig = jsonDoc.toVariant().toMap();
|
QVariantMap generatedConfig = jsonDoc.toVariant().toMap();
|
||||||
generatedConfig["KeyStoreDir"] = keyStoreDir;
|
generatedConfig["KeyStoreDir"] = keyStoreDir;
|
||||||
generatedConfig["LogEnabled"] = true;
|
|
||||||
generatedConfig["LogFile"] = networkDir + "/geth.log";
|
generatedConfig["LogFile"] = networkDir + "/geth.log";
|
||||||
generatedConfig["ClusterConfig.Fleet"] = fleet;
|
generatedConfig["ClusterConfig.Fleet"] = fleet;
|
||||||
//generatedConfig["LogLevel"] = "DEBUG";
|
|
||||||
|
|
||||||
const char* result = StartNode(QString(QJsonDocument::fromVariant(generatedConfig).toJson(QJsonDocument::Compact)).toUtf8().data());
|
const char* result = StartNode(QString(QJsonDocument::fromVariant(generatedConfig).toJson(QJsonDocument::Compact)).toUtf8().data());
|
||||||
qDebug() << "RCTStatus::startNode StartNode result: " << result;
|
qDebug() << "RCTStatus::startNode StartNode result: " << result;
|
||||||
|
|
|
@ -116,7 +116,8 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString
|
||||||
NSArray *bootnodes = [configJSON valueForKeyPath:@"ClusterConfig.BootNodes"];
|
NSArray *bootnodes = [configJSON valueForKeyPath:@"ClusterConfig.BootNodes"];
|
||||||
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];
|
NSString *logEnabled = [configJSON objectForKey:@"LogEnabled"];
|
||||||
|
NSString *logLevel = [configJSON objectForKey:@"LogLevel"];
|
||||||
char *configChars = GenerateConfig((char *)[networkDir UTF8String], (char *)[fleet UTF8String], networkId);
|
char *configChars = GenerateConfig((char *)[networkDir UTF8String], (char *)[fleet UTF8String], networkId);
|
||||||
NSString *config = [NSString stringWithUTF8String: configChars];
|
NSString *config = [NSString stringWithUTF8String: configChars];
|
||||||
configData = [config dataUsingEncoding:NSUTF8StringEncoding];
|
configData = [config dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
@ -124,8 +125,8 @@ 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:[logLevel length] != 0] forKey:@"LogEnabled"];
|
[resultingConfigJson setValue:logEnabled forKey:@"LogEnabled"];
|
||||||
[resultingConfigJson setValue:([logLevel length] == 0 ? [NSNull null] : logUrl.path) forKey:@"LogFile"];
|
[resultingConfigJson setValue:logUrl.path forKey:@"LogFile"];
|
||||||
[resultingConfigJson setValue:([logLevel length] == 0 ? [NSString stringWithUTF8String: "ERROR"] : logLevel) forKey:@"LogLevel"];
|
[resultingConfigJson setValue:([logLevel length] == 0 ? [NSString stringWithUTF8String: "ERROR"] : logLevel) forKey:@"LogLevel"];
|
||||||
|
|
||||||
[resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKeyPath:@"WhisperConfig.LightClient"];
|
[resultingConfigJson setValue:[NSNumber numberWithBool:YES] forKeyPath:@"WhisperConfig.LightClient"];
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
(ns status-im.node.models
|
(ns status-im.node.models
|
||||||
(:require [status-im.utils.config :as config]
|
(:require [status-im.utils.config :as config]
|
||||||
[status-im.utils.types :as types]))
|
[status-im.utils.types :as types]
|
||||||
|
[clojure.string :as str]
|
||||||
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
(defn- add-custom-bootnodes [config network all-bootnodes]
|
(defn- add-custom-bootnodes [config network all-bootnodes]
|
||||||
(let [bootnodes (as-> all-bootnodes $
|
(let [bootnodes (as-> all-bootnodes $
|
||||||
|
@ -12,6 +14,14 @@
|
||||||
:BootNodes bootnodes})
|
:BootNodes bootnodes})
|
||||||
config)))
|
config)))
|
||||||
|
|
||||||
|
(defn- add-log-level [config log-level]
|
||||||
|
(if (empty? log-level)
|
||||||
|
(assoc config
|
||||||
|
:LogEnabled false)
|
||||||
|
(assoc config
|
||||||
|
:LogLevel log-level
|
||||||
|
:LogEnabled true)))
|
||||||
|
|
||||||
(defn get-account-network [db address]
|
(defn get-account-network [db address]
|
||||||
(get-in db [:accounts/accounts address :network]))
|
(get-in db [:accounts/accounts address :network]))
|
||||||
|
|
||||||
|
@ -21,12 +31,21 @@
|
||||||
settings
|
settings
|
||||||
bootnodes
|
bootnodes
|
||||||
networks]} (get accounts address)
|
networks]} (get accounts address)
|
||||||
use-custom-bootnodes (get-in settings [:bootnodes network])]
|
use-custom-bootnodes (get-in settings [:bootnodes network])
|
||||||
|
log-level (or (:log-level settings)
|
||||||
|
config/log-level-status-go)]
|
||||||
(cond-> (get-in networks [network :config])
|
(cond-> (get-in networks [network :config])
|
||||||
(and
|
(and
|
||||||
config/bootnodes-settings-enabled?
|
config/bootnodes-settings-enabled?
|
||||||
use-custom-bootnodes)
|
use-custom-bootnodes)
|
||||||
(add-custom-bootnodes network bootnodes))))
|
(add-custom-bootnodes network bootnodes)
|
||||||
|
|
||||||
|
:always
|
||||||
|
(add-log-level log-level))))
|
||||||
|
|
||||||
|
(defn get-node-config [db network]
|
||||||
|
(-> (get-in (:networks/networks db) [network :config])
|
||||||
|
(add-log-level config/log-level-status-go)))
|
||||||
|
|
||||||
(defn start
|
(defn start
|
||||||
([cofx]
|
([cofx]
|
||||||
|
@ -37,10 +56,10 @@
|
||||||
(:network db))
|
(:network db))
|
||||||
node-config (if address
|
node-config (if address
|
||||||
(get-account-node-config db address)
|
(get-account-node-config db address)
|
||||||
(get-in (:networks/networks db) [network :config]))
|
(get-node-config db network))
|
||||||
node-config-json (types/clj->json node-config)]
|
node-config-json (types/clj->json node-config)]
|
||||||
{:db (assoc db
|
(log/info "Node config: " node-config-json)
|
||||||
:network network)
|
{:db (assoc db :network network)
|
||||||
:node/start node-config-json})))
|
:node/start node-config-json})))
|
||||||
|
|
||||||
(defn restart
|
(defn restart
|
||||||
|
|
|
@ -679,6 +679,9 @@
|
||||||
:network-details "Network details"
|
:network-details "Network details"
|
||||||
:remove-network "Remove network"
|
:remove-network "Remove network"
|
||||||
:network-settings "Network settings"
|
:network-settings "Network settings"
|
||||||
|
:log-level "Log level"
|
||||||
|
:log-level-settings "Log level settings"
|
||||||
|
:change-log-level "Change log level to {{log-level}}"
|
||||||
:offline-messaging "Mailserver"
|
:offline-messaging "Mailserver"
|
||||||
:offline-messaging-settings "Mailserver settings"
|
:offline-messaging-settings "Mailserver settings"
|
||||||
:edit-network-warning "Be careful! Editing the network data may disable this network for you"
|
:edit-network-warning "Be careful! Editing the network data may disable this network for you"
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
:icons/open (js/require "./resources/icons/open.svg")
|
:icons/open (js/require "./resources/icons/open.svg")
|
||||||
:icons/network (js/require "./resources/icons/network.svg")
|
:icons/network (js/require "./resources/icons/network.svg")
|
||||||
:icons/wnode (js/require "./resources/icons/wnode.svg")
|
:icons/wnode (js/require "./resources/icons/wnode.svg")
|
||||||
|
:icons/log-level (js/require "./resources/icons/wnode.svg")
|
||||||
:icons/refresh (js/require "./resources/icons/refresh.svg")
|
:icons/refresh (js/require "./resources/icons/refresh.svg")
|
||||||
:icons/newchat (js/require "./resources/icons/newchat.svg")
|
:icons/newchat (js/require "./resources/icons/newchat.svg")
|
||||||
:icons/logo (js/require "./resources/icons/logo.svg")
|
:icons/logo (js/require "./resources/icons/logo.svg")
|
||||||
|
@ -145,6 +146,7 @@
|
||||||
:icons/open (components.svg/slurp-svg "./resources/icons/open.svg")
|
:icons/open (components.svg/slurp-svg "./resources/icons/open.svg")
|
||||||
:icons/network (components.svg/slurp-svg "./resources/icons/network.svg")
|
:icons/network (components.svg/slurp-svg "./resources/icons/network.svg")
|
||||||
:icons/wnode (components.svg/slurp-svg "./resources/icons/wnode.svg")
|
:icons/wnode (components.svg/slurp-svg "./resources/icons/wnode.svg")
|
||||||
|
:icons/log-level (components.svg/slurp-svg "./resources/icons/wnode.svg")
|
||||||
:icons/refresh (components.svg/slurp-svg "./resources/icons/refresh.svg")
|
:icons/refresh (components.svg/slurp-svg "./resources/icons/refresh.svg")
|
||||||
:icons/newchat (components.svg/slurp-svg "./resources/icons/newchat.svg")
|
:icons/newchat (components.svg/slurp-svg "./resources/icons/newchat.svg")
|
||||||
:icons/logo (components.svg/slurp-svg "./resources/icons/logo.svg")
|
:icons/logo (components.svg/slurp-svg "./resources/icons/logo.svg")
|
||||||
|
@ -202,4 +204,4 @@
|
||||||
([name] (icon name nil))
|
([name] (icon name nil))
|
||||||
([name options]
|
([name options]
|
||||||
(let [icon-fn (if platform/desktop? desktop-icon mobile-icon)]
|
(let [icon-fn (if platform/desktop? desktop-icon mobile-icon)]
|
||||||
[icon-fn name options])))
|
[icon-fn name options])))
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
status-im.ui.screens.wallet.collectibles.superrare.events
|
status-im.ui.screens.wallet.collectibles.superrare.events
|
||||||
status-im.ui.screens.browser.events
|
status-im.ui.screens.browser.events
|
||||||
status-im.ui.screens.offline-messaging-settings.events
|
status-im.ui.screens.offline-messaging-settings.events
|
||||||
|
status-im.ui.screens.log-level-settings.events
|
||||||
status-im.ui.screens.privacy-policy.events
|
status-im.ui.screens.privacy-policy.events
|
||||||
status-im.ui.screens.bootnodes-settings.events
|
status-im.ui.screens.bootnodes-settings.events
|
||||||
status-im.ui.screens.currency-settings.events
|
status-im.ui.screens.currency-settings.events
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
(ns status-im.ui.screens.log-level-settings.events
|
||||||
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[status-im.i18n :as i18n]
|
||||||
|
[status-im.ui.screens.accounts.models :as accounts.models]
|
||||||
|
[status-im.utils.handlers :as handlers]
|
||||||
|
[status-im.utils.handlers-macro :as handlers-macro]))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
::save-log-level
|
||||||
|
(fn [{:keys [db now] :as cofx} [_ log-level]]
|
||||||
|
(let [settings (get-in db [:account/account :settings])]
|
||||||
|
(handlers-macro/merge-fx cofx
|
||||||
|
(accounts.models/update-settings
|
||||||
|
(if log-level
|
||||||
|
(assoc settings :log-level log-level)
|
||||||
|
(dissoc settings :log-level))
|
||||||
|
[:logout])))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:change-log-level
|
||||||
|
(fn [{:keys [db]} [_ {:keys [name value] :as log-level}]]
|
||||||
|
{:show-confirmation {:title (i18n/label :t/close-app-title)
|
||||||
|
:content (i18n/label :t/change-log-level
|
||||||
|
{:log-level name})
|
||||||
|
:confirm-button-text (i18n/label :t/close-app-button)
|
||||||
|
:on-accept #(re-frame/dispatch [::save-log-level value])
|
||||||
|
:on-cancel nil}}))
|
|
@ -0,0 +1,48 @@
|
||||||
|
(ns status-im.ui.screens.log-level-settings.styles
|
||||||
|
(:require [status-im.ui.components.colors :as colors]
|
||||||
|
[status-im.utils.platform :as platform])
|
||||||
|
(:require-macros [status-im.utils.styles :refer [defstyle]]))
|
||||||
|
|
||||||
|
(def wrapper
|
||||||
|
{:flex 1
|
||||||
|
:background-color :white})
|
||||||
|
|
||||||
|
(def log-level-item-inner
|
||||||
|
{:padding-horizontal 16})
|
||||||
|
|
||||||
|
(defstyle log-level-item
|
||||||
|
{:flex-direction :row
|
||||||
|
:background-color :white
|
||||||
|
:align-items :center
|
||||||
|
:padding-horizontal 16
|
||||||
|
:ios {:height 64}
|
||||||
|
:android {:height 56}})
|
||||||
|
|
||||||
|
(defstyle log-level-item-name-text
|
||||||
|
{:color colors/black
|
||||||
|
:ios {:font-size 17
|
||||||
|
:letter-spacing -0.2
|
||||||
|
:line-height 20}
|
||||||
|
:desktop {:font-size 16}
|
||||||
|
:android {:font-size 16}})
|
||||||
|
|
||||||
|
(defstyle log-level-item-connected-text
|
||||||
|
{:color colors/gray
|
||||||
|
:ios {:font-size 14
|
||||||
|
:margin-top 6
|
||||||
|
:letter-spacing -0.2}
|
||||||
|
:android {:font-size 12
|
||||||
|
:margin-top 2}})
|
||||||
|
|
||||||
|
(defn log-level-icon-container [current?]
|
||||||
|
{:width 40
|
||||||
|
:height 40
|
||||||
|
:border-radius 20
|
||||||
|
:background-color (if current?
|
||||||
|
colors/blue
|
||||||
|
colors/gray-light)
|
||||||
|
:align-items :center
|
||||||
|
:justify-content :center})
|
||||||
|
|
||||||
|
(defn log-level-icon [current?]
|
||||||
|
(hash-map (if platform/desktop? :tint-color :color) (if current? :white :gray)))
|
|
@ -0,0 +1,9 @@
|
||||||
|
(ns status-im.ui.screens.log-level-settings.subs
|
||||||
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[status-im.utils.config :as config]))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:settings/current-log-level
|
||||||
|
(fn [db _]
|
||||||
|
(or (get-in db [:account/account :settings :log-level])
|
||||||
|
config/log-level-status-go)))
|
|
@ -0,0 +1,61 @@
|
||||||
|
(ns status-im.ui.screens.log-level-settings.views
|
||||||
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[status-im.i18n :as i18n]
|
||||||
|
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||||
|
[status-im.ui.components.list.views :as list]
|
||||||
|
[status-im.ui.components.react :as react]
|
||||||
|
[status-im.ui.components.status-bar.view :as status-bar]
|
||||||
|
[status-im.ui.components.toolbar.view :as toolbar]
|
||||||
|
[status-im.ui.screens.log-level-settings.styles :as styles]
|
||||||
|
[status-im.utils.platform :as platform])
|
||||||
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
|
(defn- log-level-icon [current?]
|
||||||
|
[react/view (if platform/desktop?
|
||||||
|
{:style (styles/log-level-icon-container current?)}
|
||||||
|
(styles/log-level-icon-container current?))
|
||||||
|
[vector-icons/icon :icons/log-level
|
||||||
|
(if platform/desktop? {:style (styles/log-level-icon current?)}
|
||||||
|
(styles/log-level-icon current?))]])
|
||||||
|
|
||||||
|
(defn change-log-level [log-level]
|
||||||
|
(re-frame/dispatch [:change-log-level log-level]))
|
||||||
|
|
||||||
|
(defn render-row [current-log-level]
|
||||||
|
(fn [{:keys [name value] :as log-level}]
|
||||||
|
(let [current? (= value current-log-level)]
|
||||||
|
[react/touchable-highlight
|
||||||
|
{:on-press #(change-log-level log-level)
|
||||||
|
:accessibility-label :log-level-item}
|
||||||
|
[react/view styles/log-level-item
|
||||||
|
[log-level-icon current?]
|
||||||
|
[react/view styles/log-level-item-inner
|
||||||
|
[react/text {:style styles/log-level-item-name-text}
|
||||||
|
name]]]])))
|
||||||
|
|
||||||
|
(def log-levels
|
||||||
|
[{:name "DISABLED"
|
||||||
|
:value ""}
|
||||||
|
{:name "ERROR"
|
||||||
|
:value "ERROR"}
|
||||||
|
{:name "WARN"
|
||||||
|
:value "WARN"}
|
||||||
|
{:name "INFO"
|
||||||
|
:value "INFO"}
|
||||||
|
{:name "DEBUG"
|
||||||
|
:value "DEBUG"}
|
||||||
|
{:name "TRACE"
|
||||||
|
:value "TRACE"}])
|
||||||
|
|
||||||
|
(views/defview log-level-settings []
|
||||||
|
(views/letsubs [current-log-level [:settings/current-log-level]]
|
||||||
|
[react/view {:flex 1}
|
||||||
|
[status-bar/status-bar]
|
||||||
|
[toolbar/toolbar {}
|
||||||
|
toolbar/default-nav-back
|
||||||
|
[toolbar/content-title (i18n/label :t/log-level-settings)]]
|
||||||
|
[react/view styles/wrapper
|
||||||
|
[list/flat-list {:data log-levels
|
||||||
|
:default-separator? false
|
||||||
|
:key-fn :name
|
||||||
|
:render-fn (render-row current-log-level)}]]]))
|
|
@ -161,6 +161,11 @@
|
||||||
{:label-kw :t/offline-messaging
|
{:label-kw :t/offline-messaging
|
||||||
:action-fn #(re-frame/dispatch [:navigate-to :offline-messaging-settings])
|
:action-fn #(re-frame/dispatch [:navigate-to :offline-messaging-settings])
|
||||||
:accessibility-label :offline-messages-settings-button}]
|
:accessibility-label :offline-messages-settings-button}]
|
||||||
|
[profile.components/settings-item-separator]
|
||||||
|
[profile.components/settings-item
|
||||||
|
{:label-kw :t/log-level
|
||||||
|
:action-fn #(re-frame/dispatch [:navigate-to :log-level-settings])
|
||||||
|
:accessibility-label :log-level-settings-button}]
|
||||||
(when config/bootnodes-settings-enabled?
|
(when config/bootnodes-settings-enabled?
|
||||||
[profile.components/settings-item-separator])
|
[profile.components/settings-item-separator])
|
||||||
(when config/bootnodes-settings-enabled?
|
(when config/bootnodes-settings-enabled?
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
status-im.ui.screens.wallet.send.subs
|
status-im.ui.screens.wallet.send.subs
|
||||||
status-im.ui.screens.wallet.transactions.subs
|
status-im.ui.screens.wallet.transactions.subs
|
||||||
status-im.ui.screens.network-settings.subs
|
status-im.ui.screens.network-settings.subs
|
||||||
|
status-im.ui.screens.log-level-settings.subs
|
||||||
status-im.ui.screens.offline-messaging-settings.subs
|
status-im.ui.screens.offline-messaging-settings.subs
|
||||||
status-im.ui.screens.bootnodes-settings.subs
|
status-im.ui.screens.bootnodes-settings.subs
|
||||||
status-im.ui.screens.currency-settings.subs
|
status-im.ui.screens.currency-settings.subs
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
[status-im.ui.screens.network-settings.network-details.views :refer [network-details]]
|
[status-im.ui.screens.network-settings.network-details.views :refer [network-details]]
|
||||||
[status-im.ui.screens.network-settings.edit-network.views :refer [edit-network]]
|
[status-im.ui.screens.network-settings.edit-network.views :refer [edit-network]]
|
||||||
[status-im.ui.screens.extensions.views :refer [extensions-settings]]
|
[status-im.ui.screens.extensions.views :refer [extensions-settings]]
|
||||||
|
[status-im.ui.screens.log-level-settings.views :refer [log-level-settings]]
|
||||||
[status-im.ui.screens.offline-messaging-settings.views :refer [offline-messaging-settings]]
|
[status-im.ui.screens.offline-messaging-settings.views :refer [offline-messaging-settings]]
|
||||||
[status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :refer [edit-mailserver]]
|
[status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :refer [edit-mailserver]]
|
||||||
[status-im.ui.screens.extensions.add.views :refer [add-extension show-extension]]
|
[status-im.ui.screens.extensions.add.views :refer [add-extension show-extension]]
|
||||||
|
@ -95,6 +96,7 @@
|
||||||
:extensions-settings extensions-settings
|
:extensions-settings extensions-settings
|
||||||
:network-details network-details
|
:network-details network-details
|
||||||
:edit-network edit-network
|
:edit-network edit-network
|
||||||
|
:log-level-settings log-level-settings
|
||||||
:offline-messaging-settings offline-messaging-settings
|
:offline-messaging-settings offline-messaging-settings
|
||||||
:edit-mailserver edit-mailserver
|
:edit-mailserver edit-mailserver
|
||||||
:add-extension add-extension
|
:add-extension add-extension
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
(-> (get-config :LOG_LEVEL "error")
|
(-> (get-config :LOG_LEVEL "error")
|
||||||
string/lower-case
|
string/lower-case
|
||||||
keyword))
|
keyword))
|
||||||
|
(def log-level-status-go
|
||||||
|
(-> (get-config :LOG_LEVEL_STATUS_GO "")
|
||||||
|
string/upper-case))
|
||||||
(def fleet (get-config :FLEET "eth.beta"))
|
(def fleet (get-config :FLEET "eth.beta"))
|
||||||
(def default-network (get-config :DEFAULT_NETWORK))
|
(def default-network (get-config :DEFAULT_NETWORK))
|
||||||
;; the default value should be a string for `enabled?` to work correctly.
|
;; the default value should be a string for `enabled?` to work correctly.
|
||||||
|
|
Loading…
Reference in New Issue