From 980a69da488f963de4b9c8e22774827fc437b248 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 30 Aug 2023 10:00:28 -0400 Subject: [PATCH] better logs --- src/app/core/eventemitter.nim | 5 +++-- src/app/core/signals/signals_manager.nim | 7 +++---- src/app/modules/main/activity_center/controller.nim | 4 ++-- src/app/modules/main/app_search/controller.nim | 2 +- .../modules/main/chat_section/chat_content/controller.nim | 8 ++++---- .../chat_section/chat_content/messages/controller.nim | 2 +- src/app/modules/main/chat_section/controller.nim | 8 ++++---- src/app/modules/main/communities/controller.nim | 4 ++-- .../main/communities/models/curated_community_model.nim | 4 ++-- src/app/modules/main/communities/tokens/controller.nim | 4 ++-- src/app/modules/main/communities/view.nim | 8 ++++---- src/app/modules/main/controller.nim | 4 ++-- .../main/profile_section/notifications/controller.nim | 4 ++-- .../modules/main/profile_section/notifications/module.nim | 6 +++--- src/app_service/service/community/service.nim | 4 ++-- 15 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/app/core/eventemitter.nim b/src/app/core/eventemitter.nim index bd85638bd2..74e97db2d1 100644 --- a/src/app/core/eventemitter.nim +++ b/src/app/core/eventemitter.nim @@ -1,5 +1,5 @@ import # system libs - tables + tables, chronicles import # deps uuids @@ -46,7 +46,8 @@ proc disconnect*(this: EventEmitter, handlerId: UUID) = this.events[k].del handlerId proc emit*(this:EventEmitter, name:string, args:Args): void = - echo "Emitting ", name + if name != "signal:chronicles-log": + debug "Emitting event", name if this.events.hasKey(name): # collect the handlers before executing them # because of 'once' proc, we also mutate diff --git a/src/app/core/signals/signals_manager.nim b/src/app/core/signals/signals_manager.nim index 59f6131a87..708bde5af9 100644 --- a/src/app/core/signals/signals_manager.nim +++ b/src/app/core/signals/signals_manager.nim @@ -34,8 +34,6 @@ QtObject: error "Invalid signal received", data = statusSignal return - trace "Raw signal data", data = $jsonSignal - var signal:Signal try: signal = self.decode(jsonSignal) @@ -56,14 +54,15 @@ QtObject: self.processSignal(signal) proc decode(self: SignalsManager, jsonSignal: JsonNode): Signal = - echo jsonSignal let signalString = jsonSignal{"type"}.getStr var signalType: SignalType try: signalType = parseEnum[SignalType](signalString) except CatchableError: raise newException(ValueError, "Unknown signal received: " & signalString) - + + if signalType != SignalType.ChroniclesLogs: + debug "Status-go Signal", signal=jsonSignal result = case signalType: of SignalType.Message: MessageSignal.fromEvent(jsonSignal) of SignalType.MessageDelivered: MessageDeliveredSignal.fromEvent(jsonSignal) diff --git a/src/app/modules/main/activity_center/controller.nim b/src/app/modules/main/activity_center/controller.nim index 8fc2446456..594798fd6b 100644 --- a/src/app/modules/main/activity_center/controller.nim +++ b/src/app/modules/main/activity_center/controller.nim @@ -1,4 +1,4 @@ -import Tables, stint +import Tables, stint, chronicles import ./io_interface import ../../../global/app_signals @@ -99,7 +99,7 @@ proc getContactDetails*(self: Controller, contactId: string): ContactDetails = return self.contactsService.getContactDetails(contactId) proc getCommunityById*(self: Controller, communityId: string): CommunityDto = - echo "getCommunityById from activity_center module" + debug "getCommunityById from activity_center module", communityId return self.communityService.getCommunityById(communityId) proc getActivityCenterNotifications*(self: Controller): seq[ActivityCenterNotificationDto] = diff --git a/src/app/modules/main/app_search/controller.nim b/src/app/modules/main/app_search/controller.nim index 4198f1f7ab..0ef6edabc7 100644 --- a/src/app/modules/main/app_search/controller.nim +++ b/src/app/modules/main/app_search/controller.nim @@ -89,7 +89,7 @@ proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] = return self.chatService.getChannelGroups() proc getCommunityById*(self: Controller, communityId: string): CommunityDto = - echo "getCommunityById from app_search module" + debug "getCommunityById from app_search module", communityId return self.communityService.getCommunityById(communityId) proc getChatDetailsForChatTypes*(self: Controller, types: seq[ChatType]): seq[ChatDto] = diff --git a/src/app/modules/main/chat_section/chat_content/controller.nim b/src/app/modules/main/chat_section/chat_content/controller.nim index e6fb5be3b9..877f0aa30d 100644 --- a/src/app/modules/main/chat_section/chat_content/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/controller.nim @@ -1,4 +1,4 @@ -import NimQml +import NimQml, chronicles import json import io_interface @@ -179,9 +179,9 @@ proc init*(self: Controller) = var args = ChatUpdateArgs(e) for chat in args.chats: if self.chatId == chat.id: - echo "Chat content" + debug "Chat content", chatId=chat.id self.delegate.onChatEdited(chat) - echo "Chat done" + debug "Chat done", chatId=chat.id proc getMyChatId*(self: Controller): string = return self.chatId @@ -190,7 +190,7 @@ proc getChatDetails*(self: Controller): ChatDto = return self.chatService.getChatById(self.chatId) proc getCommunityDetails*(self: Controller): CommunityDto = - echo "getCommunityById from chat_content module" + debug "getCommunityById from chat_content module", communityId=self.sectionId return self.communityService.getCommunityById(self.sectionId) proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string, largeImage: string] = diff --git a/src/app/modules/main/chat_section/chat_content/messages/controller.nim b/src/app/modules/main/chat_section/chat_content/messages/controller.nim index e96b773847..f6d61f2c12 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/controller.nim @@ -240,7 +240,7 @@ proc getChatDetails*(self: Controller): ChatDto = return self.chatService.getChatById(self.chatId) proc getCommunityDetails*(self: Controller): CommunityDto = - echo "getCommunityById from messages module" + debug "getCommunityById from messages module", communityId=self.sectionId return self.communityService.getCommunityById(self.sectionId) proc getOneToOneChatNameAndImage*(self: Controller): diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 590a530c1f..fff7c9ac5a 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -1,4 +1,4 @@ -import Tables, sugar, sequtils, strutils +import Tables, sugar, sequtils, strutils, chronicles import io_interface @@ -156,11 +156,11 @@ proc init*(self: Controller) = var args = ChatUpdateArgs(e) for chat in args.chats: let belongsToCommunity = chat.communityId.len > 0 - echo "Chat section" + debug "Chat section", id=chat.id discard self.delegate.addOrUpdateChat(chat, belongsToCommunity, self.events, self.settingsService, self.nodeConfigurationService, self.contactService, self.chatService, self.communityService, self.messageService, self.gifService, self.mailserversService, setChatAsActive = false) - echo "Chat section done" + debug "Chat section done", id=chat.id self.events.on(SIGNAL_CHAT_CREATED) do(e: Args): var args = CreatedChatArgs(e) @@ -383,7 +383,7 @@ proc isCommunity*(self: Controller): bool = return self.isCommunitySection proc getMyCommunity*(self: Controller): CommunityDto = - echo "getCommunityById from chat_section module" + debug "getCommunityById from chat_section module", communityId=self.sectionId return self.communityService.getCommunityById(self.sectionId) proc getCategories*(self: Controller, communityId: string): seq[Category] = diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index a89f58c3b3..b1d4cde81e 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -1,4 +1,4 @@ -import stint, std/strutils +import stint, std/strutils, chronicles import ./io_interface import ../../../core/signals/types @@ -205,7 +205,7 @@ proc getAllCommunities*(self: Controller): seq[CommunityDto] = result = self.communityService.getAllCommunities() proc getCommunityById*(self: Controller, communityId: string): CommunityDto = - echo "getCommunityById from communities module" + debug "getCommunityById from communities module", communityId=communityId result = self.communityService.getCommunityById(communityId) proc getCuratedCommunities*(self: Controller): seq[CommunityDto] = diff --git a/src/app/modules/main/communities/models/curated_community_model.nim b/src/app/modules/main/communities/models/curated_community_model.nim index b962862d9e..c75a8be337 100644 --- a/src/app/modules/main/communities/models/curated_community_model.nim +++ b/src/app/modules/main/communities/models/curated_community_model.nim @@ -1,4 +1,4 @@ -import NimQml, Tables +import NimQml, Tables, chronicles import curated_community_item import ../../../shared_models/[token_permissions_model, token_permission_item] @@ -162,6 +162,6 @@ QtObject: proc setPermissionItems*(self: CuratedCommunityModel, itemId: string, items: seq[TokenPermissionItem]) = let idx = self.findIndexById(itemId) if idx == -1: - echo "Tried to set permission items on an item that doesn't exist. Item ID: ", itemId + debug "Tried to set permission items on an item that doesn't exist. Item ID: ", itemId return self.items[idx].setPermissionModelItems(items) \ No newline at end of file diff --git a/src/app/modules/main/communities/tokens/controller.nim b/src/app/modules/main/communities/tokens/controller.nim index f7f1bb741a..d0ac85915c 100644 --- a/src/app/modules/main/communities/tokens/controller.nim +++ b/src/app/modules/main/communities/tokens/controller.nim @@ -1,4 +1,4 @@ -import stint +import stint, chronicles import ./io_interface as community_tokens_module_interface import ../../../../../app_service/service/community_tokens/service as community_tokens_service @@ -138,5 +138,5 @@ proc getTokenMasterToken*(self: Controller, communityId: string): CommunityToken return self.communityTokensService.getTokenMasterToken(communityId) proc getCommunityById*(self: Controller, communityId: string): CommunityDto = - echo "getCommunityById from tokens module" + debug "getCommunityById from tokens module", communityId return self.communityService.getCommunityById(communityId) \ No newline at end of file diff --git a/src/app/modules/main/communities/view.nim b/src/app/modules/main/communities/view.nim index f8a7d3429a..dba3f42cf6 100644 --- a/src/app/modules/main/communities/view.nim +++ b/src/app/modules/main/communities/view.nim @@ -1,4 +1,4 @@ -import NimQml, json, strutils, sequtils +import NimQml, json, strutils, sequtils, chronicles import ./io_interface import ../../shared_models/[section_model, section_item, section_details, token_list_model, token_list_item, @@ -319,7 +319,7 @@ QtObject: let sharedAddresses = map(parseJson(addressesToShare).getElems(), proc(x:JsonNode):string = x.getStr()) self.delegate.checkPermissions(communityId, sharedAddresses) except Exception as e: - echo "Error updating token model with addresses: ", e.msg + debug "Error updating token model with addresses: ", msg=e.msg proc getSpectatedCommunityPermissionModel(self: View): QVariant {.slot.} = return self.spectatedCommunityPermissionModelVariant @@ -658,14 +658,14 @@ QtObject: let addressesArray = map(parseJson(addressesToShare).getElems(), proc(x:JsonNode):string = x.getStr()) self.delegate.requestToJoinCommunityWithAuthentication(communityId, ensName, addressesArray, airdropAddress) except Exception as e: - echo "Error requesting to join community with authentication and shared addresses: ", e.msg + debug "Error requesting to join community with authentication and shared addresses: ", msg=e.msg proc editSharedAddressesWithAuthentication*(self: View, communityId: string, addressesToShare: string, airdropAddress: string) {.slot.} = try: let addressesArray = map(parseJson(addressesToShare).getElems(), proc(x:JsonNode):string = x.getStr()) self.delegate.editSharedAddressesWithAuthentication(communityId, addressesArray, airdropAddress) except Exception as e: - echo "Error editing shared addresses with authentication: ", e.msg + debug "Error editing shared addresses with authentication: ", msg=e.msg proc getCommunityPublicKeyFromPrivateKey*(self: View, communityPrivateKey: string): string {.slot.} = result = self.delegate.getCommunityPublicKeyFromPrivateKey(communityPrivateKey) diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index d18eca1c7b..cff83e6f22 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -1,4 +1,4 @@ -import chronicles, stint, tables +import chronicles, stint, tables, chronicles import ../../global/app_sections_config as conf import ../../global/global_singleton import ../../global/app_signals @@ -501,7 +501,7 @@ proc switchTo*(self: Controller, sectionId, chatId, messageId: string) = self.events.emit(SIGNAL_MAKE_SECTION_CHAT_ACTIVE, data) proc getCommunityById*(self: Controller, communityId: string): CommunityDto = - echo "getCommunityById from main module" + debug "getCommunityById from main module", communityId return self.communityService.getCommunityById(communityId) proc getStatusForContactWithId*(self: Controller, publicKey: string): StatusUpdateDto = diff --git a/src/app/modules/main/profile_section/notifications/controller.nim b/src/app/modules/main/profile_section/notifications/controller.nim index 784e9d4508..c5758f8ea3 100644 --- a/src/app/modules/main/profile_section/notifications/controller.nim +++ b/src/app/modules/main/profile_section/notifications/controller.nim @@ -80,9 +80,9 @@ proc init*(self: Controller) = self.events.on(SIGNAL_CHAT_UPDATE) do(e: Args): var args = ChatUpdateArgs(e) for chat in args.chats: - echo "notifications" + debug "notifications", chatId=chat.id self.delegate.addChat(chat) - echo "notifications done" + debug "notifications done", chatId=chat.id self.events.on(SIGNAL_CHAT_RENAMED) do(e: Args): var args = ChatRenameArgs(e) diff --git a/src/app/modules/main/profile_section/notifications/module.nim b/src/app/modules/main/profile_section/notifications/module.nim index 083cbd9aba..ae53159718 100644 --- a/src/app/modules/main/profile_section/notifications/module.nim +++ b/src/app/modules/main/profile_section/notifications/module.nim @@ -133,11 +133,11 @@ method addChat*(self: Module, chatDto: ChatDto) = let ind = self.view.exemptionsModel().findIndexForItemId(chatDto.id) if(ind != -1): return - echo "Create item" + debug "Create item", chatId=chatDto.id let item = self.createChatItem(chatDto) - echo "created item" + debug "created item", chatId=chatDto.id self.view.exemptionsModel().addItem(item) - echo "added item" + debug "added item", chatId=chatDto.id method addChat*(self: Module, itemId: string) = let ind = self.view.exemptionsModel().findIndexForItemId(itemId) diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 3fc9544c14..aaedfceab8 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -727,7 +727,7 @@ QtObject: return toSeq(self.communities.keys) proc getCommunityTokenBySymbol*(self: Service, communityId: string, symbol: string): CommunityTokenDto = - echo "getCommunityById from getCommunityTokenBySymbol" + debug "getCommunityById from getCommunityTokenBySymbol" let community = self.getCommunityById(communityId) for metadata in community.communityTokensMetadata: if metadata.symbol == symbol: @@ -2003,7 +2003,7 @@ QtObject: return community.declinedRequestsToJoin[indexDeclined].publicKey proc checkChatHasPermissions*(self: Service, communityId: string, chatId: string): bool = - echo "getCommunityById from checkChatHasPermissions" + debug "getCommunityById from checkChatHasPermissions" let community = self.getCommunityById(communityId) for id, tokenPermission in community.tokenPermissions: if TokenPermissionType(tokenPermission.`type`) == TokenPermissionType.View or TokenPermissionType(tokenPermission.`type`) == TokenPermissionType.ViewAndPost: