Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use chronincles for logging #17272

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/modules/main/wallet_section/accounts/model.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, Tables, strutils, stew/shims/strformat, std/sequtils, logging
import NimQml, Tables, strutils, stew/shims/strformat, std/sequtils, chronicles

import ./item
import ../../../shared_models/currency_amount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, stint
import logging
import chronicles

import ./collectibles_item
import web3/ethtypes as eth
Expand Down
28 changes: 14 additions & 14 deletions src/app/modules/main/wallet_section/activity/controller.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, logging, std/json, sequtils, sugar, options, strutils
import NimQml, chronicles, std/json, sequtils, sugar, options, strutils
import tables, stint, sets

import model
Expand Down Expand Up @@ -94,7 +94,7 @@ QtObject:
defer: self.status.setErrorCode(res.errorCode.int)

if res.errorCode != ErrorCodeSuccess:
error "error fetching activity entries: ", res.errorCode
error "error fetching activity entries: ",code = res.errorCode
return

let entries = self.backendToPresentation(res.activities)
Expand Down Expand Up @@ -124,7 +124,7 @@ QtObject:
if self.eventsHandler.hasSessionId():
let res = backend_activity.stopActivityFilterSession(self.sessionId())
if res.error != nil:
error "error stopping the previous session of activity fitlering: ", res.error
error "error stopping the previous session of activity fitlering: ", error = res.error
self.eventsHandler.clearSessionId()

# start a new filter session
Expand All @@ -149,7 +149,7 @@ QtObject:
let response = backend_activity.resetActivityFilterSession(self.sessionId(), FETCH_BATCH_COUNT_DEFAULT)
if response.error != nil:
self.status.setLoadingData(false)
error "error fetching activity entries from start: ", response.error
error "error fetching activity entries from start: ", error = response.error
return

proc loadMoreItems(self: Controller) {.slot.} =
Expand All @@ -158,23 +158,23 @@ QtObject:
let response = backend_activity.getMoreForActivityFilterSession(self.sessionId(), FETCH_BATCH_COUNT_DEFAULT)
if response.error != nil:
self.status.setLoadingData(false)
error "error fetching more activity entries: ", response.error
error "error fetching more activity entries: ", error = response.error
return

proc updateCollectiblesModel*(self: Controller) {.slot.} =
self.status.setLoadingCollectibles(true)
let res = backend_activity.getActivityCollectiblesAsync(self.sessionId(), self.chainIds, self.addresses, 0, FETCH_COLLECTIBLES_BATCH_COUNT_DEFAULT)
if res.error != nil:
self.status.setLoadingCollectibles(false)
error "error fetching collectibles: ", res.error
error "error fetching collectibles: ", error = res.error
return

proc loadMoreCollectibles*(self: Controller) {.slot.} =
self.status.setLoadingCollectibles(true)
let res = backend_activity.getActivityCollectiblesAsync(self.sessionId(), self.chainIds, self.addresses, self.collectiblesModel.getCount(), FETCH_COLLECTIBLES_BATCH_COUNT_DEFAULT)
if res.error != nil:
self.status.setLoadingCollectibles(false)
error "error fetching collectibles: ", res.error
error "error fetching collectibles: ", error = res.error
return

proc resetFilter*(self: Controller) {.slot.} =
Expand Down Expand Up @@ -203,7 +203,7 @@ QtObject:
let resJson = backend_activity.getOldestActivityTimestampAsync(self.sessionId(), self.addresses)
if resJson.error != nil:
self.status.setLoadingStartTimestamp(false)
error "error requesting oldest activity timestamp: ", resJson.error
error "error requesting oldest activity timestamp: ", error = resJson.error
return

proc checkAllSavedAddresses(self: Controller) =
Expand Down Expand Up @@ -270,7 +270,7 @@ QtObject:
let res = fromJson(jsonObj, backend_activity.GetRecipientsResponse)

if res.errorCode != ErrorCodeSuccess:
error "error fetching recipients: ", res.errorCode
error "error fetching recipients: ", code = res.errorCode
return

self.recipientsModel.addAddresses(res.addresses, res.offset, res.hasMore)
Expand All @@ -281,7 +281,7 @@ QtObject:
let res = fromJson(jsonObj, backend_activity.GetOldestTimestampResponse)

if res.errorCode != ErrorCodeSuccess:
error "error fetching start timestamp: ", res.errorCode
error "error fetching start timestamp: ", code = res.errorCode
return

self.status.setStartTimestamp(res.timestamp)
Expand All @@ -292,14 +292,14 @@ QtObject:
let res = fromJson(jsonObj, backend_activity.GetCollectiblesResponse)

if res.errorCode != ErrorCodeSuccess:
error "error fetching collectibles: ", res.errorCode
error "error fetching collectibles: ", code = res.errorCode
return

try:
let items = res.collectibles.map(header => collectibleToItem(header))
self.collectiblesModel.setItems(items, res.offset, res.hasMore)
except Exception as e:
error "Error converting activity entries: ", e.msg
error "Error converting activity entries: ", code = e.msg
)

proc newController*(currencyService: currency_service.Service,
Expand Down Expand Up @@ -464,7 +464,7 @@ QtObject:
let res = backend_activity.getRecipientsAsync(self.sessionId(), self.chainIds, self.addresses, 0, FETCH_RECIPIENTS_BATCH_COUNT_DEFAULT)
if res.error != nil or res.result.kind != JBool:
self.status.setLoadingRecipients(false)
error "error fetching recipients: ", res.error, "; kind ", res.result.kind
error "error fetching recipients: ", error = res.error, kind = res.result.kind
return

# If the request was enqueued and already waiting for a response, we don't need to do anything
Expand All @@ -477,7 +477,7 @@ QtObject:
let res = backend_activity.getRecipientsAsync(self.sessionId(), self.chainIds, self.addresses, self.recipientsModel.getCount(), FETCH_RECIPIENTS_BATCH_COUNT_DEFAULT)
if res.error != nil:
self.status.setLoadingRecipients(false)
error "error fetching more recipient entries: ", res.error
error "error fetching more recipient entries: ", error = res.error
return

# If the request was enqueued and waiting for an answer, we don't need to do anything
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/main/wallet_section/activity/entry.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, json, stew/shims/strformat, sequtils, strutils, logging, stint
import NimQml, json, stew/shims/strformat, sequtils, strutils, chronicles, stint

import backend/activity as backend
import app/modules/shared_models/currency_amount
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/main/wallet_section/activity/model.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, logging, options
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, chronicles, options

import ./entry

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, Tables, strutils, sequtils, logging
import NimQml, Tables, strutils, sequtils, chronicles

type
ModelRole {.pure.} = enum
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/onboarding/module.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NimQml, chronicles, json, strutils
import logging
import chronicles

import io_interface
import view, controller
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/shared_models/collectibles_model.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, stint, json
import logging
import chronicles

import ./collectibles_entry
import backend/collectibles as backend_collectibles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, logging, std/json, sequtils, strutils
import NimQml, chronicles, std/json, sequtils, strutils
import stint

import app/modules/shared_models/collectibles_entry
Expand Down Expand Up @@ -64,11 +64,11 @@ QtObject:
let res = fromJson(response, backend_collectibles.GetCollectiblesByUniqueIDResponse)

if res.errorCode != ErrorCodeSuccess:
error "error fetching collectible details: ", res.errorCode
error "error fetching collectible details: ", code = res.errorCode
return

if len(res.collectibles) != 1:
error "unexpected number of items fetching collectible details: ", len(res.collectibles)
error "unexpected number of items fetching collectible details: ", len = len(res.collectibles)
return

let collectible = res.collectibles[0]
Expand Down Expand Up @@ -109,7 +109,7 @@ QtObject:
discard backend_collectibles.fetchCollectionSocialsAsync(id.contractID)
if response.error != nil:
self.setIsDetailedEntryLoading(false)
error "error fetching collectible details: ", response.error
error "error fetching collectible details: ", error = response.error
return

proc resetDetailedCollectible*(self: Controller) {.slot.} =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NimQml, logging, std/json, sequtils, strutils, options
import NimQml, chronicles, std/json, sequtils, strutils, options
import tables

import app/core/eventemitter
Expand Down Expand Up @@ -43,7 +43,7 @@ QtObject:
responseJson = parseJson(data.message)

if responseJson.kind != JObject:
error "unexpected json type", responseJson.kind
error "unexpected json type", kind = responseJson.kind
return
let callback = self.eventHandlers[data.eventType]
callback(responseJson)
Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/shared_modules/collectibles/controller.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NimQml, std/json, sequtils, sugar, strutils
import stint, logging, Tables
import stint, chronicles, Tables

import app/modules/shared_models/collectibles_entry
import app/modules/shared_models/collectibles_model
Expand Down Expand Up @@ -144,9 +144,9 @@ QtObject:
self.model.setIsFetching(false)
self.model.setIsError(true)
self.fetchFromStart = true
error "error fetching collectibles entries: ", response.error
error "error fetching collectibles entries: ", error = response.error
except Exception as e:
error "error fetching collectibles entries: ", e.msg
error "error fetching collectibles entries: ", error = e.msg
self.model.setIsFetching(false)
self.model.setIsError(true)
self.fetchFromStart = true
Expand Down Expand Up @@ -175,7 +175,7 @@ QtObject:
let isError = res.errorCode != backend_collectibles.ErrorCodeSuccess

if isError:
error "error fetching collectibles entries: ", res.errorCode
error "error fetching collectibles entries: ", code = res.errorCode
self.model.setIsError(true)
self.model.setIsFetching(false)
return
Expand All @@ -194,7 +194,7 @@ QtObject:
self.model.updateItems(self.tempItems)
self.tempItems = @[]
except Exception as e:
error "Error converting activity entries: ", e.msg
error "Error converting activity entries: ", error = e.msg

self.model.setIsFetching(false)
self.setOwnershipStatus(res.ownershipStatus)
Expand Down
10 changes: 5 additions & 5 deletions src/backend/activity.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import times, stew/shims/strformat, options, logging
import times, stew/shims/strformat, options, chronicles
import json, json_serialization
import core, response_type
import stint
Expand Down Expand Up @@ -99,7 +99,7 @@ proc fromJson[T](jsonObj: JsonNode, TT: typedesc[Option[T]]): Option[T] =

proc fromJson[T](jsonObj: JsonNode, TT: typedesc[seq[T]]): seq[T] =
if jsonObj.kind != JArray:
error "Expected array, got: ", jsonObj.kind
error "Expected array, got: ", kind = jsonObj.kind
return @[]

result = newSeq[T](jsonObj.len)
Expand Down Expand Up @@ -572,7 +572,7 @@ proc fromJson*(e: JsonNode, T: typedesc[FilterResponse]): FilterResponse {.inlin
for i in 0 ..< jsonEntries.len:
backendEntities[i] = fromJson(jsonEntries[i], ActivityEntry)
elif jsonEntries.kind != JNull:
error "Invalid activities field in FilterResponse; kind: ", jsonEntries.kind
error "Invalid activities field in FilterResponse; kind: ", kind=jsonEntries.kind

result = T(
activities: backendEntities,
Expand Down Expand Up @@ -635,7 +635,7 @@ proc newActivityFilterSession*(
try:
let res = startActivityFilterSessionV2(addresses, chainIds, filter, count)
if res.error != nil:
error "error starting a new session of activity fitlering: ", res.error
error "error starting a new session of activity fitlering", err = res.error
return (int32(-1), false)
return (int32(res.result.getInt()), true)
except:
Expand All @@ -645,7 +645,7 @@ proc updateFilterForSession*(sessionId: int32, filter: ActivityFilter, count: in
try:
let res = updateActivityFilterForSession(sessionId, filter, count)
if res.error != nil:
error "error updating fitler for session: ", res.error
error "error updating fitler for session", err = res.error
return false
except:
return false
Expand Down
6 changes: 3 additions & 3 deletions src/backend/transactions.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Tables, json, stint, json_serialization, stew/shims/strformat, logging
import Tables, json, stint, json_serialization, stew/shims/strformat, chronicles

import ./core as core

Expand Down Expand Up @@ -100,7 +100,7 @@ proc buildTransactionsFromRoute*(resultOut: var JsonNode, uuid: string, slippage
let response = core.callPrivateRPC("wallet_buildTransactionsFromRoute", payload)
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error building transactions", err = e.msg
return e.msg

proc sendRouterTransactionsWithSignatures*(resultOut: var JsonNode, uuid: string, signatures: TransactionsSignatures): string =
Expand All @@ -116,5 +116,5 @@ proc sendRouterTransactionsWithSignatures*(resultOut: var JsonNode, uuid: string
let response = core.callPrivateRPC("wallet_sendRouterTransactionsWithSignatures", payload)
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error sending transactions", err = e.msg
return e.msg
14 changes: 7 additions & 7 deletions src/backend/wallet.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import json, tables, json_serialization, logging
import json, tables, json_serialization, chronicles
import core, response_type
from ./gen import rpc

Expand Down Expand Up @@ -53,7 +53,7 @@ proc signMessage*(resultOut: var JsonNode, message: string, address: string, has
let response = signMessage(message, address, hashedPassword)
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error signing message", err = e.msg
return e.msg


Expand All @@ -67,7 +67,7 @@ proc buildTransaction*(resultOut: var JsonNode, chainId: int, sendTxArgsJson: st
let response = buildTransaction(chainId, sendTxArgsJson)
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error building transaction", err = e.msg
return e.msg


Expand All @@ -82,7 +82,7 @@ proc buildRawTransaction*(resultOut: var JsonNode, chainId: int, sendTxArgsJson:
let response = buildRawTransaction(chainId, sendTxArgsJson, signature)
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error building raw transaction", err = e.msg
return e.msg

## Sends the tx with signature on provided chain, setting tx type
Expand All @@ -98,7 +98,7 @@ proc sendTransactionWithSignature*(resultOut: var JsonNode, chainId: int, txType
let response = sendTransactionWithSignature(chainId, txType, sendTxArgsJson, signature)
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error sending transaction", err = e.msg
return e.msg

proc hashTypedData*(resultOut: var JsonNode, data: string): string =
Expand All @@ -107,7 +107,7 @@ proc hashTypedData*(resultOut: var JsonNode, data: string): string =
var response = Json.decode(rawResponse, RpcResponse[JsonNode])
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error hashing data", err = e.msg
return e.msg

proc hashTypedDataV4*(resultOut: var JsonNode, data: string): string =
Expand All @@ -116,7 +116,7 @@ proc hashTypedDataV4*(resultOut: var JsonNode, data: string): string =
var response = Json.decode(rawResponse, RpcResponse[JsonNode])
return prepareResponse(resultOut, response)
except Exception as e:
warn e.msg
warn "error hashing data v4", err = e.msg
return e.msg

proc prepareDataForSuggestedRoutes(
Expand Down
Loading