summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-30 14:33:54 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-30 14:33:54 +0300
commit4b1b0623887c24f45257c409ce332af9b765b50d (patch)
treef299367542d90eaa869a5e5010f1ac2dbfc81136 /src
parentChange the minimum width for modals (diff)
downloadnheko-4b1b0623887c24f45257c409ce332af9b765b50d.tar.xz
Enable debug logs
Diffstat (limited to 'src')
-rw-r--r--src/Logging.cpp7
-rw-r--r--src/Olm.cpp36
-rw-r--r--src/UserSettingsPage.cpp2
-rw-r--r--src/main.cpp2
-rw-r--r--src/timeline/TimelineView.cpp17
-rw-r--r--src/ui/InfoMessage.cpp2
6 files changed, 36 insertions, 30 deletions
diff --git a/src/Logging.cpp b/src/Logging.cpp
index 298949cf..686274d8 100644
--- a/src/Logging.cpp
+++ b/src/Logging.cpp
@@ -1,4 +1,5 @@
 #include "Logging.h"
+#include "config/nheko.h"
 
 #include "spdlog/sinks/rotating_file_sink.h"
 #include "spdlog/sinks/stdout_color_sinks.h"
@@ -32,6 +33,12 @@ init(const std::string &file_path)
         db_logger  = std::make_shared<spdlog::logger>("db", std::begin(sinks), std::end(sinks));
         crypto_logger =
           std::make_shared<spdlog::logger>("crypto", std::begin(sinks), std::end(sinks));
+
+        if (nheko::enable_debug_log) {
+                db_logger->set_level(spdlog::level::trace);
+                ui_logger->set_level(spdlog::level::trace);
+                crypto_logger->set_level(spdlog::level::trace);
+        }
 }
 
 std::shared_ptr<spdlog::logger>
diff --git a/src/Olm.cpp b/src/Olm.cpp
index dd8a8fbe..c1598570 100644
--- a/src/Olm.cpp
+++ b/src/Olm.cpp
@@ -92,7 +92,7 @@ handle_olm_message(const OlmMessage &msg)
                 auto payload = try_olm_decryption(msg.sender_key, cipher.second);
 
                 if (!payload.is_null()) {
-                        nhlog::crypto()->info("decrypted olm payload: {}", payload.dump(2));
+                        nhlog::crypto()->debug("decrypted olm payload: {}", payload.dump(2));
                         create_inbound_megolm_session(msg.sender, msg.sender_key, payload);
                         return;
                 }
@@ -146,7 +146,7 @@ handle_pre_key_olm_message(const std::string &sender,
         }
 
         auto plaintext = json::parse(std::string((char *)output.data(), output.size()));
-        nhlog::crypto()->info("decrypted message: \n {}", plaintext.dump(2));
+        nhlog::crypto()->debug("decrypted message: \n {}", plaintext.dump(2));
 
         try {
                 cache::client()->saveOlmSession(sender_key, std::move(inbound_session));
@@ -206,11 +206,11 @@ try_olm_decryption(const std::string &sender_key, const mtx::events::msg::OlmCip
                         text = olm::client()->decrypt_message(session->get(), msg.type, msg.body);
                         cache::client()->saveOlmSession(id, std::move(session.value()));
                 } catch (const mtx::crypto::olm_exception &e) {
-                        nhlog::crypto()->info("failed to decrypt olm message ({}, {}) with {}: {}",
-                                              msg.type,
-                                              sender_key,
-                                              id,
-                                              e.what());
+                        nhlog::crypto()->debug("failed to decrypt olm message ({}, {}) with {}: {}",
+                                               msg.type,
+                                               sender_key,
+                                               id,
+                                               e.what());
                         continue;
                 } catch (const lmdb::error &e) {
                         nhlog::crypto()->critical("failed to save session: {}", e.what());
@@ -339,19 +339,19 @@ void
 handle_key_request_message(const mtx::events::msg::KeyRequest &req)
 {
         if (req.algorithm != MEGOLM_ALGO) {
-                nhlog::crypto()->info("ignoring key request {} with invalid algorithm: {}",
-                                      req.request_id,
-                                      req.algorithm);
+                nhlog::crypto()->debug("ignoring key request {} with invalid algorithm: {}",
+                                       req.request_id,
+                                       req.algorithm);
                 return;
         }
 
         // Check if we were the sender of the session being requested.
         if (req.sender_key != olm::client()->identity_keys().curve25519) {
-                nhlog::crypto()->info("ignoring key request {} because we were not the sender: "
-                                      "\nrequested({}) ours({})",
-                                      req.request_id,
-                                      req.sender_key,
-                                      olm::client()->identity_keys().curve25519);
+                nhlog::crypto()->debug("ignoring key request {} because we were not the sender: "
+                                       "\nrequested({}) ours({})",
+                                       req.request_id,
+                                       req.sender_key,
+                                       olm::client()->identity_keys().curve25519);
                 return;
         }
 
@@ -380,7 +380,7 @@ handle_key_request_message(const mtx::events::msg::KeyRequest &req)
         }
 
         if (!utils::respondsToKeyRequests(req.room_id)) {
-                nhlog::crypto()->info("ignoring all key requests for room {}", req.room_id);
+                nhlog::crypto()->debug("ignoring all key requests for room {}", req.room_id);
                 return;
         }
 
@@ -433,7 +433,7 @@ send_megolm_key_to_device(const std::string &user_id,
 
                   if ((device_keys.find(curveKey) == device_keys.end()) ||
                       (device_keys.find(edKey) == device_keys.end())) {
-                          nhlog::net()->info("ignoring malformed keys for device {}", device_id);
+                          nhlog::net()->debug("ignoring malformed keys for device {}", device_id);
                           return;
                   }
 
@@ -499,7 +499,7 @@ send_megolm_key_to_device(const std::string &user_id,
                             body["messages"][user_id] = json::object();
 
                             auto device = retrieved_devices.begin()->second;
-                            nhlog::net()->info("{} : \n {}", device_id, device.dump(2));
+                            nhlog::net()->debug("{} : \n {}", device_id, device.dump(2));
 
                             json device_msg;
 
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index c9b9fb82..9245702e 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -34,7 +34,7 @@
 #include "ui/FlatButton.h"
 #include "ui/ToggleButton.h"
 
-#include "version.h"
+#include "config/nheko.h"
 
 UserSettings::UserSettings() { load(); }
 
diff --git a/src/main.cpp b/src/main.cpp
index 4ceb535d..3e33c198 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -35,7 +35,7 @@
 #include "MatrixClient.h"
 #include "RunGuard.h"
 #include "Utils.h"
-#include "version.h"
+#include "config/nheko.h"
 
 #if defined(Q_OS_MAC)
 #include "emoji/MacHelper.h"
diff --git a/src/timeline/TimelineView.cpp b/src/timeline/TimelineView.cpp
index 07de25b6..6198b296 100644
--- a/src/timeline/TimelineView.cpp
+++ b/src/timeline/TimelineView.cpp
@@ -354,8 +354,7 @@ TimelineView::parseEncryptedEvent(const mtx::events::EncryptedEvent<mtx::events:
         body["origin_server_ts"] = e.origin_server_ts;
         body["unsigned"]         = e.unsigned_data;
 
-        nhlog::crypto()->info("decrypted event: {}", e.event_id);
-        nhlog::crypto()->debug("decrypted data: \n {}", body.dump(2));
+        nhlog::crypto()->debug("decrypted event: {}", e.event_id);
 
         json event_array = json::array();
         event_array.push_back(body);
@@ -746,7 +745,7 @@ TimelineView::sendNextPendingMessage()
                 m.widget->markSent();
 
         if (m.is_encrypted) {
-                nhlog::ui()->info("[{}] sending encrypted event", m.txn_id);
+                nhlog::ui()->debug("[{}] sending encrypted event", m.txn_id);
                 prepareEncryptedMessage(std::move(m));
                 return;
         }
@@ -1330,7 +1329,7 @@ TimelineView::prepareEncryptedMessage(const PendingMessage &msg)
                         return;
                 }
 
-                nhlog::ui()->info("creating new outbound megolm session");
+                nhlog::ui()->debug("creating new outbound megolm session");
 
                 // Create a new outbound megolm session.
                 auto outbound_session  = olm::client()->init_outbound_group_session();
@@ -1413,7 +1412,7 @@ TimelineView::prepareEncryptedMessage(const PendingMessage &msg)
 
                                           if ((device_keys.find(curveKey) == device_keys.end()) ||
                                               (device_keys.find(edKey) == device_keys.end())) {
-                                                  nhlog::net()->info(
+                                                  nhlog::net()->debug(
                                                     "ignoring malformed keys for device {}",
                                                     device_id.get());
                                                   continue;
@@ -1512,15 +1511,15 @@ TimelineView::handleClaimedKeys(std::shared_ptr<StateKeeper> keeper,
                 return;
         }
 
-        nhlog::net()->info("claimed keys for {}", user_id);
+        nhlog::net()->debug("claimed keys for {}", user_id);
 
         if (res.one_time_keys.size() == 0) {
-                nhlog::net()->info("no one-time keys found for user_id: {}", user_id);
+                nhlog::net()->debug("no one-time keys found for user_id: {}", user_id);
                 return;
         }
 
         if (res.one_time_keys.find(user_id) == res.one_time_keys.end()) {
-                nhlog::net()->info("no one-time keys found for user_id: {}", user_id);
+                nhlog::net()->debug("no one-time keys found for user_id: {}", user_id);
                 return;
         }
 
@@ -1532,7 +1531,7 @@ TimelineView::handleClaimedKeys(std::shared_ptr<StateKeeper> keeper,
 
         for (const auto &rd : retrieved_devices) {
                 const auto device_id = rd.first;
-                nhlog::net()->info("{} : \n {}", device_id, rd.second.dump(2));
+                nhlog::net()->debug("{} : \n {}", device_id, rd.second.dump(2));
 
                 // TODO: Verify signatures
                 auto otk = rd.second.begin()->at("key");
diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp
index e107b18f..e9de20cc 100644
--- a/src/ui/InfoMessage.cpp
+++ b/src/ui/InfoMessage.cpp
@@ -1,5 +1,5 @@
-#include "Config.h"
 #include "InfoMessage.h"
+#include "Config.h"
 
 #include <QDateTime>
 #include <QPainter>