From 056dde0190519dc9d8d0a1c4d93158148ef86421 Mon Sep 17 00:00:00 2001 From: andrey Date: Thu, 25 Jun 2020 16:44:08 +0200 Subject: [PATCH] [#10870] "Invalid timbre logging level" after upgrade from 1.4 to 1.4.1 or relogin on 1.4.1 Signed-off-by: andrey --- .env | 3 +- .env.e2e | 3 +- .env.jenkins | 3 +- .env.nightly | 3 +- .env.release | 3 +- src/status_im/constants.cljs | 2 +- src/status_im/core.cljs | 5 ++- src/status_im/desktop/core.cljs | 2 - src/status_im/multiaccounts/login/core.cljs | 4 +- src/status_im/utils/config.cljs | 7 +-- src/status_im/utils/logging/core.cljs | 48 ++++++++++----------- 11 files changed, 35 insertions(+), 48 deletions(-) diff --git a/.env b/.env index 558b2e6cb6..a639b47094 100644 --- a/.env +++ b/.env @@ -8,8 +8,7 @@ EXTENSIONS=0 FLEET=eth.prod GROUP_CHATS_ENABLED=1 HARDWALLET_ENABLED=1 -LOG_LEVEL_STATUS_GO=info -LOG_LEVEL=debug +LOG_LEVEL=info MAILSERVER_CONFIRMATIONS_ENABLED=1 PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=1 diff --git a/.env.e2e b/.env.e2e index dfb41e9c21..5f7874e0ea 100644 --- a/.env.e2e +++ b/.env.e2e @@ -6,8 +6,7 @@ EXTENSIONS=0 FLEET=eth.prod GROUP_CHATS_ENABLED=1 HARDWALLET_ENABLED=1 -LOG_LEVEL_STATUS_GO=info -LOG_LEVEL=debug +LOG_LEVEL=info MAILSERVER_CONFIRMATIONS_ENABLED=0 PAIRING_POPUP_DISABLED=1 PFS_ENCRYPTION_ENABLED=1 diff --git a/.env.jenkins b/.env.jenkins index 84332f08ae..bef6e03065 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -7,8 +7,7 @@ EXTENSIONS=0 FLEET=eth.prod GROUP_CHATS_ENABLED=1 HARDWALLET_ENABLED=1 -LOG_LEVEL_STATUS_GO=info -LOG_LEVEL=debug +LOG_LEVEL=info MAILSERVER_CONFIRMATIONS_ENABLED=1 MAINNET_WARNING_ENABLED=1 PFS_ENCRYPTION_ENABLED=1 diff --git a/.env.nightly b/.env.nightly index cd28b859e4..4b516cc816 100644 --- a/.env.nightly +++ b/.env.nightly @@ -5,8 +5,7 @@ ETHEREUM_DEV_CLUSTER=1 EXTENSIONS=0 FLEET=eth.prod GROUP_CHATS_ENABLED=1 -LOG_LEVEL_STATUS_GO=info -LOG_LEVEL=debug +LOG_LEVEL=info MAILSERVER_CONFIRMATIONS_ENABLED=1 MAINNET_WARNING_ENABLED=1 PFS_ENCRYPTION_ENABLED=1 diff --git a/.env.release b/.env.release index 707e6e5ea8..fa83e76841 100644 --- a/.env.release +++ b/.env.release @@ -5,8 +5,7 @@ ETHEREUM_DEV_CLUSTER=0 EXTENSIONS=0 FLEET=eth.prod GROUP_CHATS_ENABLED=1 -LOG_LEVEL_STATUS_GO= -LOG_LEVEL=info +LOG_LEVEL= MAILSERVER_CONFIRMATIONS_ENABLED=1 MAINNET_WARNING_ENABLED=1 PFS_ENCRYPTION_ENABLED=1 diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 6807068e15..4c4885a774 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -108,7 +108,7 @@ :currency :usd :appearance 0 :waku-enabled true - :log-level config/log-level-status-go}) + :log-level config/log-level}) (defn default-visible-tokens [chain] (get-in default-multiaccount [:wallet/visible-tokens chain])) diff --git a/src/status_im/core.cljs b/src/status_im/core.cljs index 7c15e8dc4f..4653916dd0 100644 --- a/src/status_im/core.cljs +++ b/src/status_im/core.cljs @@ -17,7 +17,8 @@ [status-im.utils.error-handler :as error-handler] [status-im.utils.logging.core :as utils.logs] [status-im.utils.platform :as platform] - [status-im.utils.snoopy :as snoopy])) + [status-im.utils.snoopy :as snoopy] + [status-im.utils.config :as config])) (set! interop/next-tick js/setTimeout) (set! batching/fake-raf #(js/setTimeout % 0)) @@ -79,7 +80,7 @@ :reagent-render views/main})) (defn init [] - (utils.logs/init-logs) + (utils.logs/init-logs config/log-level) (error-handler/register-exception-handler!) (enableScreens) (re-frame/dispatch-sync [:init/app-started]) diff --git a/src/status_im/desktop/core.cljs b/src/status_im/desktop/core.cljs index d73ff32df8..433d5e365f 100644 --- a/src/status_im/desktop/core.cljs +++ b/src/status_im/desktop/core.cljs @@ -8,7 +8,6 @@ [status-im.ui.components.react :as react] [status-im.utils.snoopy :as snoopy] [status-im.utils.error-handler :as error-handler] - [status-im.utils.logging.core :as utils.logs] [status-im.ui.screens.desktop.views :as desktop-views] [status-im.desktop.deep-links :as deep-links] [status-im.utils.config :as config])) @@ -39,7 +38,6 @@ desktop-views/main)}))) (defn init [] - (utils.logs/init-logs) (error-handler/register-exception-handler!) (re-frame/dispatch-sync [:init/app-started]) (.registerComponent ^js app-registry "StatusIm" #(reagent/reactify-component app-root)) diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index f6f3a6db37..a27111cf10 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -195,7 +195,7 @@ (contact/initialize-contacts) (stickers/init-stickers-packs) (mobile-network/on-network-status-change) - (logging/set-log-level multiaccount) + (logging/set-log-level (:log-level multiaccount)) (multiaccounts/switch-preview-privacy-mode-flag)))) (defn get-new-auth-method [auth-method save-password?] @@ -256,7 +256,7 @@ :mailserver-topics {} :default-mailserver true}) (multiaccounts/switch-preview-privacy-mode-flag) - (logging/set-log-level multiaccount) + (logging/set-log-level (:log-level multiaccount)) (when-not platform/desktop? (initialize-wallet accounts nil))))) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 49ce086c27..97df9d0d3c 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -44,12 +44,7 @@ ;; CONFIG VALUES (def log-level - (-> (get-config :LOG_LEVEL "error") - string/lower-case - keyword)) -(def log-level-status-go - (-> (get-config :LOG_LEVEL_STATUS_GO "") - string/upper-case)) + (string/upper-case (get-config :LOG_LEVEL ""))) (def fleet (get-config :FLEET "eth.staging")) (def default-network (get-config :DEFAULT_NETWORK)) (def pow-target (js/parseFloat (get-config :POW_TARGET "0.0001"))) diff --git a/src/status_im/utils/logging/core.cljs b/src/status_im/utils/logging/core.cljs index e2984870dd..6a20becdf1 100644 --- a/src/status_im/utils/logging/core.cljs +++ b/src/status_im/utils/logging/core.cljs @@ -1,18 +1,18 @@ (ns status-im.utils.logging.core - (:require [clojure.string :as clojure.string] - [re-frame.core :as re-frame] + (:require [re-frame.core :as re-frame] [status-im.native-module.core :as status] [status-im.utils.fx :as fx] [status-im.utils.types :as types] [status-im.utils.handlers :as handlers] [status-im.utils.email :as mail] [taoensso.timbre :as log] - [status-im.utils.config :as config] [status-im.i18n :as i18n] [status-im.utils.platform :as platform] [status-im.utils.build :as build] [status-im.transport.utils :as transport.utils] - [status-im.utils.datetime :as datetime])) + [status-im.utils.datetime :as datetime] + [clojure.string :as string] + [status-im.utils.config :as config])) (def report-email "error-reports@status.im") (def max-log-entries 1000) @@ -22,17 +22,19 @@ (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 init-logs [level] + (when-not (string/blank? level) + (log/set-level! (-> level + string/lower-case + keyword)) + (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)) + (string/join "\n" @logs-queue)) (re-frame/reg-fx :logs/archive-logs @@ -44,18 +46,14 @@ (re-frame/reg-fx :logs/set-level - (fn [log-level] - (log/set-level! log-level))) + (fn [level] + (init-logs level))) (fx/defn set-log-level - [{:keys [db]} multiaccount] - (let [log-level (if-let [level (get multiaccount :log-level)] - (if (clojure.string/blank? level) "ERROR" level) - config/log-level-status-go)] - {:db (assoc-in db [:multiaccount :log-level] log-level) - :logs/set-level (-> log-level - clojure.string/lower-case - keyword)})) + [{:keys [db]} log-level] + (let [log-level (or log-level config/log-level)] + {:db (assoc-in db [:multiaccount :log-level] log-level) + :logs/set-level log-level})) (fx/defn send-logs [{:keys [db]}] @@ -112,10 +110,10 @@ :node-info :peers-summary]}] (let [build-number (if platform/desktop? build/version build/build-no) build-version (str build/version " (" build-number ")") - separator (clojure.string/join (take 40 (repeat "-"))) + separator (string/join (take 40 (repeat "-"))) [enode-id ip-address port] (transport.utils/extract-url-components (:enode node-info))] - (clojure.string/join + (string/join "\n" (concat [(i18n/label :t/report-bug-email-template)] [separator