diff --git a/lib/db/db_version_migration.dart b/lib/db/db_version_migration.dart index 7fc07c2bb..e18c4b720 100644 --- a/lib/db/db_version_migration.dart +++ b/lib/db/db_version_migration.dart @@ -45,10 +45,7 @@ class DbVersionMigrator with WalletDB { // safe to skip to v11 for campfire fromVersion = 11; } - Logging.instance.logd( - "Running migrate fromVersion $fromVersion", - level: LogLevel.Warning, - ); + Logging.instance.i("Running migrate fromVersion $fromVersion"); switch (fromVersion) { case 0: await DB.instance.hive.openBox(DB.boxNameAllWalletsData); @@ -102,12 +99,13 @@ class DbVersionMigrator with WalletDB { try { latestSetId = await client.getLelantusLatestCoinId(); - } catch (e) { + } catch (e, s) { // default to 2 for now latestSetId = 2; - Logging.instance.logd( + Logging.instance.w( "Failed to fetch latest coin id during firo db migrate: $e \nUsing a default value of 2", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } } diff --git a/lib/db/hive/db.dart b/lib/db/hive/db.dart index be289d4cd..0e9449094 100644 --- a/lib/db/hive/db.dart +++ b/lib/db/hive/db.dart @@ -166,9 +166,10 @@ class DB { AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String); return false; } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Error, ${jsonObject["coin"]} does not exist, $name wallet cannot be loaded", - level: LogLevel.Error, + error: e, + stackTrace: s, ); return true; } @@ -343,7 +344,7 @@ class DB { await DB.instance.deleteBoxFromDisk(boxName: "theme"); return true; } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("$e $s", error: e, stackTrace: s); return false; } } diff --git a/lib/db/sqlite/firo_cache.dart b/lib/db/sqlite/firo_cache.dart index a3b2b8359..c2ebbfe66 100644 --- a/lib/db/sqlite/firo_cache.dart +++ b/lib/db/sqlite/firo_cache.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; -import 'package:flutter/foundation.dart'; import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart'; import 'package:mutex/mutex.dart'; import 'package:sqlite3/sqlite3.dart'; @@ -20,16 +19,6 @@ part 'firo_cache_reader.dart'; part 'firo_cache_worker.dart'; part 'firo_cache_writer.dart'; -/// Temporary debugging log function for this file -void _debugLog(Object? object) { - if (kDebugMode) { - Logging.instance.logd( - object, - level: LogLevel.Debug, - ); - } -} - abstract class _FiroCache { static const int _setCacheVersion = 2; static const int _tagsCacheVersion = 2; @@ -116,7 +105,8 @@ abstract class _FiroCache { VACUUM; """, ); - _debugLog( + + Logging.instance.d( "_deleteAllCache() " "duration = ${DateTime.now().difference(start)}", ); diff --git a/lib/db/sqlite/firo_cache_coordinator.dart b/lib/db/sqlite/firo_cache_coordinator.dart index 84ad64b23..6adeba520 100644 --- a/lib/db/sqlite/firo_cache_coordinator.dart +++ b/lib/db/sqlite/firo_cache_coordinator.dart @@ -42,14 +42,8 @@ abstract class FiroCacheCoordinator { ? await usedTagsCacheFile.length() : 0; - Logging.instance.logd( - "Spark cache used tags size: $tagsSize", - level: LogLevel.Debug, - ); - Logging.instance.logd( - "Spark cache anon set size: $setSize", - level: LogLevel.Debug, - ); + Logging.instance.d("Spark cache used tags size: $tagsSize"); + Logging.instance.d("Spark cache anon set size: $setSize"); final int bytes = tagsSize + setSize; @@ -111,10 +105,7 @@ abstract class FiroCacheCoordinator { progressUpdated?.call(prevSize, meta.size); if (prevMeta?.blockHash == meta.blockHash) { - Logging.instance.logd( - "prevMeta?.blockHash == meta.blockHash", - level: LogLevel.Debug, - ); + Logging.instance.d("prevMeta?.blockHash == meta.blockHash"); return; } diff --git a/lib/electrumx_rpc/cached_electrumx_client.dart b/lib/electrumx_rpc/cached_electrumx_client.dart index 558561f13..c3b8ab56a 100644 --- a/lib/electrumx_rpc/cached_electrumx_client.dart +++ b/lib/electrumx_rpc/cached_electrumx_client.dart @@ -100,17 +100,17 @@ class CachedElectrumXClient { } // save set to db await box.put(groupId, set); - Logging.instance.logd( + Logging.instance.d( "Updated current anonymity set for ${cryptoCurrency.identifier} with group ID $groupId", - level: LogLevel.Info, ); } return set; } catch (e, s) { - Logging.instance.logd( - "Failed to process CachedElectrumX.getAnonymitySet(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Failed to process CachedElectrumX.getAnonymitySet(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -155,16 +155,17 @@ class CachedElectrumXClient { await box.put(txHash, result); } - // Logging.instance.log("using fetched result", level: LogLevel.Info); + // Logging.instance.log("using fetched result"); return result; } else { - // Logging.instance.log("using cached result", level: LogLevel.Info); + // Logging.instance.log("using cached result"); return Map.from(cachedTx); } } catch (e, s) { - Logging.instance.logd( - "Failed to process CachedElectrumX.getTransaction(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Failed to process CachedElectrumX.getTransaction(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -212,9 +213,10 @@ class CachedElectrumXClient { return resultingList; } catch (e, s) { - Logging.instance.logd( - "Failed to process CachedElectrumX.getUsedCoinSerials(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Failed to process CachedElectrumX.getUsedCoinSerials(): ", + error: e, + stackTrace: s, ); rethrow; } diff --git a/lib/electrumx_rpc/client_manager.dart b/lib/electrumx_rpc/client_manager.dart index 3199b840f..8cd9d5324 100644 --- a/lib/electrumx_rpc/client_manager.dart +++ b/lib/electrumx_rpc/client_manager.dart @@ -69,9 +69,10 @@ class ClientManager { _heightCompleters[key]!.complete(event.height); } }, - onError: (Object err, StackTrace s) => Logging.instance.logd( - "ClientManager listen: $err\n$s", - level: LogLevel.Error, + onError: (Object err, StackTrace s) => Logging.instance.e( + "ClientManager listen", + error: err, + stackTrace: s, ), ); } diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 92bc7ab8a..2691adf5a 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -233,10 +233,9 @@ class ElectrumXClient { if (!_prefs.torKillSwitch) { // Then we'll just proceed and connect to ElectrumX through // clearnet at the bottom of this function. - Logging.instance.logd( + Logging.instance.w( "Tor preference set but Tor is not enabled, killswitch not set," " connecting to Electrum adapter through clearnet", - level: LogLevel.Warning, ); } else { // ... But if the killswitch is set, then we throw an exception. @@ -398,9 +397,13 @@ class ElectrumXClient { } else { rethrow; } - } catch (e) { + } catch (e, s) { final errorMessage = e.toString(); - Logging.instance.logd("$host $e", level: LogLevel.Debug); + Logging.instance.w( + "$host $e", + error: e, + stackTrace: s, + ); if (errorMessage.contains("JSON-RPC error")) { currentFailoverIndex = _failovers.length; } @@ -535,9 +538,8 @@ class ElectrumXClient { ).timeout( const Duration(seconds: 30), onTimeout: () { - Logging.instance.logd( + Logging.instance.d( "ElectrumxClient.ping timed out with retryCount=$retryCount, host=$_host", - level: LogLevel.Debug, ); }, ) as bool; @@ -562,10 +564,7 @@ class ElectrumXClient { command: 'blockchain.headers.subscribe', ); if (response == null) { - Logging.instance.logd( - "getBlockHeadTip returned null response", - level: LogLevel.Error, - ); + Logging.instance.e("getBlockHeadTip returned null response"); throw 'getBlockHeadTip returned null response'; } return Map.from(response as Map); @@ -756,14 +755,15 @@ class ElectrumXClient { try { final data = List>.from(response[i] as List); result.add(data); - } catch (e) { + } catch (e, s) { // to ensure we keep same length of responses as requests/args // add empty list on error result.add([]); - Logging.instance.logd( + Logging.instance.e( "getBatchUTXOs failed to parse response=${response[i]}: $e", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } } @@ -826,15 +826,13 @@ class ElectrumXClient { bool verbose = true, String? requestID, }) async { - Logging.instance.logd( + Logging.instance.d( "attempting to fetch blockchain.transaction.get...", - level: LogLevel.Info, ); await checkElectrumAdapter(); final dynamic response = await getElectrumAdapter()!.getTransaction(txHash); - Logging.instance.logd( + Logging.instance.d( "Fetching blockchain.transaction.get finished", - level: LogLevel.Info, ); if (!verbose) { @@ -863,17 +861,15 @@ class ElectrumXClient { String blockhash = "", String? requestID, }) async { - Logging.instance.logd( + Logging.instance.d( "attempting to fetch lelantus.getanonymityset...", - level: LogLevel.Info, ); await checkElectrumAdapter(); final Map response = await (getElectrumAdapter() as FiroElectrumClient) .getLelantusAnonymitySet(groupId: groupId, blockHash: blockhash); - Logging.instance.logd( + Logging.instance.d( "Fetching lelantus.getanonymityset finished", - level: LogLevel.Info, ); return response; } @@ -886,16 +882,14 @@ class ElectrumXClient { dynamic mints, String? requestID, }) async { - Logging.instance.logd( + Logging.instance.d( "attempting to fetch lelantus.getmintmetadata...", - level: LogLevel.Info, ); await checkElectrumAdapter(); final dynamic response = await (getElectrumAdapter() as FiroElectrumClient) .getLelantusMintData(mints: mints); - Logging.instance.logd( + Logging.instance.d( "Fetching lelantus.getmintmetadata finished", - level: LogLevel.Info, ); return response; } @@ -906,9 +900,8 @@ class ElectrumXClient { String? requestID, required int startNumber, }) async { - Logging.instance.logd( + Logging.instance.d( "attempting to fetch lelantus.getusedcoinserials...", - level: LogLevel.Info, ); await checkElectrumAdapter(); @@ -919,9 +912,8 @@ class ElectrumXClient { response = await (getElectrumAdapter() as FiroElectrumClient) .getLelantusUsedCoinSerials(startNumber: startNumber); // TODO add 2 minute timeout. - Logging.instance.logd( + Logging.instance.d( "Fetching lelantus.getusedcoinserials finished", - level: LogLevel.Info, ); retryCount--; @@ -934,16 +926,14 @@ class ElectrumXClient { /// /// ex: 1 Future getLelantusLatestCoinId({String? requestID}) async { - Logging.instance.logd( + Logging.instance.d( "attempting to fetch lelantus.getlatestcoinid...", - level: LogLevel.Info, ); await checkElectrumAdapter(); final int response = await (getElectrumAdapter() as FiroElectrumClient).getLatestCoinId(); - Logging.instance.logd( + Logging.instance.d( "Fetching lelantus.getlatestcoinid finished", - level: LogLevel.Info, ); return response; } @@ -977,12 +967,11 @@ class ElectrumXClient { coinGroupId: coinGroupId, startBlockHash: startBlockHash, ); - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.getSparkAnonymitySet(coinGroupId" "=$coinGroupId, startBlockHash=$startBlockHash). " "coins.length: ${(response["coins"] as List?)?.length}" "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Info, ); return response; } catch (e) { @@ -1020,7 +1009,7 @@ class ElectrumXClient { // ); // // return tags; - // } catch (e) { + // } catch (e, s) { // Logging.instance.log(e, level: LogLevel.Error); // rethrow; // } @@ -1055,7 +1044,7 @@ class ElectrumXClient { // level: LogLevel.Info, // ); // return List>.from(response); - // } catch (e) { + // } catch (e, s) { // Logging.instance.log(e, level: LogLevel.Error); // rethrow; // } @@ -1068,20 +1057,22 @@ class ElectrumXClient { String? requestID, }) async { try { - Logging.instance.logd( + Logging.instance.d( "attempting to fetch spark.getsparklatestcoinid...", - level: LogLevel.Info, ); await checkElectrumAdapter(); final int response = await (getElectrumAdapter() as FiroElectrumClient) .getSparkLatestCoinId(); - Logging.instance.logd( + Logging.instance.d( "Fetching spark.getsparklatestcoinid finished", - level: LogLevel.Info, ); return response; - } catch (e) { - Logging.instance.logd(e, level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + e, + error: e, + stackTrace: s, + ); rethrow; } } @@ -1101,15 +1092,18 @@ class ElectrumXClient { .map((e) => e.toHexReversedFromBase64) .toSet(); - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.getMempoolTxids(). " "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Info, ); return txids; - } catch (e) { - Logging.instance.logd(e, level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + e, + error: e, + stackTrace: s, + ); rethrow; } } @@ -1146,15 +1140,14 @@ class ElectrumXClient { ); } - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.getMempoolSparkData(txids: $txids). " "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Info, ); return result; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); rethrow; } } @@ -1178,16 +1171,19 @@ class ElectrumXClient { final map = Map.from(response as Map); final tags = List>.from(map["tagsandtxids"] as List); - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.getSparkUnhashedUsedCoinsTagsWithTxHashes(" "startNumber=$startNumber). # of tags fetched=${tags.length}, " "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Info, ); return tags; - } catch (e) { - Logging.instance.logd(e, level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + e, + error: e, + stackTrace: s, + ); rethrow; } } @@ -1199,9 +1195,8 @@ class ElectrumXClient { }) async { try { const command = "spark.getsparkanonymitysetmeta"; - Logging.instance.logd( + Logging.instance.d( "[${getElectrumAdapter()?.host}] => attempting to fetch $command...", - level: LogLevel.Info, ); final start = DateTime.now(); @@ -1222,18 +1217,21 @@ class ElectrumXClient { size: map["size"] as int, ); - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.getSparkAnonymitySetMeta(" "requestID=$requestID, " "coinGroupId=$coinGroupId" "). Set meta=$result, " "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Debug, ); return result; - } catch (e) { - Logging.instance.logd(e, level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + e, + error: e, + stackTrace: s, + ); rethrow; } } @@ -1264,7 +1262,7 @@ class ElectrumXClient { final result = map["coins"] as List; - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.getSparkAnonymitySetBySector(" "requestID=$requestID, " "coinGroupId=$coinGroupId, " @@ -1273,12 +1271,15 @@ class ElectrumXClient { "endIndex=$endIndex" "). # of coins=${result.length}, " "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Debug, ); return result; - } catch (e) { - Logging.instance.logd(e, level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + e, + error: e, + stackTrace: s, + ); rethrow; } } @@ -1301,16 +1302,19 @@ class ElectrumXClient { ], ); - Logging.instance.logd( + Logging.instance.d( "Finished ElectrumXClient.isMasterNodeCollateral, " "response: $response, " "Duration=${DateTime.now().difference(start)}", - level: LogLevel.Info, ); return response as bool; - } catch (e) { - Logging.instance.logd(e, level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + e, + error: e, + stackTrace: s, + ); rethrow; } } @@ -1369,7 +1373,7 @@ class ElectrumXClient { } catch (e, s) { final String msg = "Error parsing fee rate. Response: $response" "\nResult: $response\nError: $e\nStack trace: $s"; - Logging.instance.logd(msg, level: LogLevel.Fatal); + Logging.instance.e(msg, error: e, stackTrace: s); throw Exception(msg); } } catch (e) { diff --git a/lib/electrumx_rpc/subscribable_electrumx_client.dart b/lib/electrumx_rpc/subscribable_electrumx_client.dart index f06771906..8c3e1849b 100644 --- a/lib/electrumx_rpc/subscribable_electrumx_client.dart +++ b/lib/electrumx_rpc/subscribable_electrumx_client.dart @@ -503,7 +503,7 @@ // _responseHandler(response); // } catch (e, s) { // Logging.instance -// .log("JsonRPC jsonDecode: $e\n$s", level: LogLevel.Error); +// .log("JsonRPC jsonDecode", error: e, stackTrace: s,); // rethrow; // } finally { // _responseData = []; diff --git a/lib/main.dart b/lib/main.dart index 43e076879..fde2ce42a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -209,10 +209,10 @@ void main(List args) async { ), ); } catch (e, s) { - Logging.instance.logd( - "Cannot migrate mobile database\n$e $s", - level: LogLevel.Error, - printFullLength: true, + Logging.instance.w( + "Cannot migrate mobile database", + error: e, + stackTrace: s, ); } } @@ -558,9 +558,8 @@ class _MaterialAppWithThemeState extends ConsumerState // call reset to clear cached value await resetOpenPath(); - Logging.instance.logd( + Logging.instance.d( "This is the .swb content from intent: ${ref.read(openedFromSWBFileStringStateProvider.state).state}", - level: LogLevel.Info, ); } diff --git a/lib/models/exchange/change_now/cn_exchange_estimate.dart b/lib/models/exchange/change_now/cn_exchange_estimate.dart index c1aa4e7fb..b5d75a40e 100644 --- a/lib/models/exchange/change_now/cn_exchange_estimate.dart +++ b/lib/models/exchange/change_now/cn_exchange_estimate.dart @@ -113,8 +113,11 @@ class CNExchangeEstimate { toAmount: Decimal.parse(json["toAmount"].toString()), ); } catch (e, s) { - Logging.instance - .logd("Failed to parse: $json \n$e\n$s", level: LogLevel.Fatal); + Logging.instance.e( + "Failed to parse: $json", + error: e, + stackTrace: s, + ); rethrow; } } diff --git a/lib/models/exchange/change_now/estimated_exchange_amount.dart b/lib/models/exchange/change_now/estimated_exchange_amount.dart index 9cc634215..62eee2f60 100644 --- a/lib/models/exchange/change_now/estimated_exchange_amount.dart +++ b/lib/models/exchange/change_now/estimated_exchange_amount.dart @@ -57,8 +57,11 @@ class EstimatedExchangeAmount { networkFee: Decimal.tryParse(json["networkFee"].toString()), ); } catch (e, s) { - Logging.instance - .logd("Failed to parse: $json \n$e\n$s", level: LogLevel.Fatal); + Logging.instance.e( + "Failed to parse: $json", + error: e, + stackTrace: s, + ); rethrow; } } diff --git a/lib/models/exchange/change_now/exchange_transaction_status.dart b/lib/models/exchange/change_now/exchange_transaction_status.dart index 055a3757c..7874b8b80 100644 --- a/lib/models/exchange/change_now/exchange_transaction_status.dart +++ b/lib/models/exchange/change_now/exchange_transaction_status.dart @@ -187,7 +187,7 @@ class ExchangeTransactionStatus { }); factory ExchangeTransactionStatus.fromJson(Map json) { - Logging.instance.logd(json, printFullLength: true, level: LogLevel.Info); + Logging.instance.d(json, stackTrace: StackTrace.current); try { return ExchangeTransactionStatus( status: changeNowTransactionStatusFromStringIgnoreCase( @@ -228,7 +228,7 @@ class ExchangeTransactionStatus { payload: json["payload"] as Object?, ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Fatal); + Logging.instance.f("", error: e, stackTrace: s); rethrow; } } diff --git a/lib/models/exchange/response_objects/estimate.dart b/lib/models/exchange/response_objects/estimate.dart index eddcd4c5d..233959277 100644 --- a/lib/models/exchange/response_objects/estimate.dart +++ b/lib/models/exchange/response_objects/estimate.dart @@ -47,8 +47,11 @@ class Estimate { kycRating: kycRating, ); } catch (e, s) { - Logging.instance - .logd("Estimate.fromMap(): $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "Estimate.fromMap()", + error: e, + stackTrace: s, + ); rethrow; } } diff --git a/lib/models/exchange/response_objects/fixed_rate_market.dart b/lib/models/exchange/response_objects/fixed_rate_market.dart index faa9d4268..a52fe5768 100644 --- a/lib/models/exchange/response_objects/fixed_rate_market.dart +++ b/lib/models/exchange/response_objects/fixed_rate_market.dart @@ -54,10 +54,7 @@ class FixedRateMarket { minerFee: Decimal.tryParse(json["minerFee"].toString()), ); } catch (e, s) { - Logging.instance.logd( - "FixedRateMarket.fromMap(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("FixedRateMarket.fromMap(): ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/models/exchange/simpleswap/sp_currency.dart b/lib/models/exchange/simpleswap/sp_currency.dart index 17bd6ebf5..9de40720f 100644 --- a/lib/models/exchange/simpleswap/sp_currency.dart +++ b/lib/models/exchange/simpleswap/sp_currency.dart @@ -59,10 +59,7 @@ class SPCurrency { warningsTo: json["warnings_to"] as List, ); } catch (e, s) { - Logging.instance.logd( - "SPCurrency.fromJson failed to parse: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("SPCurrency.fromJson failed to parse: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/models/isar/stack_theme.dart b/lib/models/isar/stack_theme.dart index d7b8023b9..efa2f7d05 100644 --- a/lib/models/isar/stack_theme.dart +++ b/lib/models/isar/stack_theme.dart @@ -13,6 +13,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; + import '../../app_config.dart'; import '../../utilities/extensions/impl/box_shadow.dart'; import '../../utilities/extensions/impl/gradient.dart'; @@ -1884,10 +1885,7 @@ class StackTheme { (map[mainNetId] as String).toBigIntFromHex.toInt(), ); } else { - Logging.instance.logd( - "Color not found in theme for $mainNetId", - level: LogLevel.Error, - ); + Logging.instance.w("Color not found in theme for $mainNetId"); } } diff --git a/lib/networking/http.dart b/lib/networking/http.dart index fcb8beea3..80ea57c37 100644 --- a/lib/networking/http.dart +++ b/lib/networking/http.dart @@ -53,10 +53,7 @@ class HTTP { response.statusCode, ); } catch (e, s) { - Logging.instance.logd( - "HTTP.get() rethrew: $e\n$s", - level: LogLevel.Info, - ); + Logging.instance.w("HTTP.get() rethrew: ", error: e, stackTrace: s); rethrow; } finally { httpClient.close(force: true); @@ -99,10 +96,7 @@ class HTTP { response.statusCode, ); } catch (e, s) { - Logging.instance.logd( - "HTTP.post() rethrew: $e\n$s", - level: LogLevel.Info, - ); + Logging.instance.w("HTTP.post() rethrew: ", error: e, stackTrace: s); rethrow; } finally { httpClient.close(force: true); @@ -119,9 +113,10 @@ class HTTP { onDone: () => completer.complete( Uint8List.fromList(bytes), ), - onError: (Object err, StackTrace s) => Logging.instance.logd( - "Http wrapper layer listen: $err\n$s", - level: LogLevel.Error, + onError: (Object err, StackTrace s) => Logging.instance.e( + "Http wrapper layer listen", + error: err, + stackTrace: s, ), ); return completer.future; diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart index 0c7c666be..d8aae6d6d 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart @@ -178,10 +178,7 @@ class _FrostCreateStep2State extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (context.mounted) { return await showDialog( context: context, diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart index e1d7c081e..ec565cb59 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart @@ -178,10 +178,7 @@ class _FrostCreateStep3State extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (context.mounted) { return await showDialog( diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart index fed7cf360..3c59c7524 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart @@ -219,10 +219,7 @@ class _FrostCreateStep5State extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); // pop progress dialog if (context.mounted && !progressPopped) { diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart index 36d7138c0..740baafc3 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart @@ -81,10 +81,7 @@ class _FrostReshareStep1aState extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart index 4dc485795..7224e2acb 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart @@ -117,10 +117,7 @@ class _FrostReshareStep1bState extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart index 4432ebd0d..b10730c3a 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart @@ -204,10 +204,7 @@ class _FrostReshareStep1cState extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (context.mounted) { await showDialog( diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart index 3a2a7a64e..b54b6041b 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart @@ -79,10 +79,7 @@ class _FrostReshareStep2abdState extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart index fe53e562b..92a3a195b 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart @@ -59,10 +59,7 @@ class _FrostReshareStep2cState extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart index e027d294c..d4fc876c1 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart @@ -70,10 +70,7 @@ class _FrostReshareStep3abdState extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( context: context, diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart index c3147c656..dd081d121 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart @@ -88,10 +88,7 @@ class _FrostReshareStep4State extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( context: context, diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart index ce9f250f2..83fa55944 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart @@ -104,10 +104,7 @@ class _FrostReshareStep5State extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( context: context, diff --git a/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart b/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart index f7aec5a82..88f7c3b26 100644 --- a/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart +++ b/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart @@ -171,9 +171,10 @@ class _RestoreFrostMsWalletViewState ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, + Logging.instance.e( + "", + error: e, + stackTrace: s, ); if (mounted) { @@ -234,9 +235,8 @@ class _RestoreFrostMsWalletViewState ); if (qrResult == null) { - Logging.instance.logd( + Logging.instance.d( "Qr scanning cancelled", - level: LogLevel.Info, ); } else { // TODO [prio=low]: Validate QR code data. @@ -248,9 +248,10 @@ class _RestoreFrostMsWalletViewState } } } on PlatformException catch (e, s) { - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to get camera permissions while trying to scan qr code: ", + error: e, + stackTrace: s, ); } } diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart index 034cb6dbc..1ab649f26 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart @@ -274,10 +274,7 @@ class _NewWalletRecoveryPhraseWarningViewState return (wallet, fetchedMnemonic); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); rethrow; } } diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index 06619e582..a5aec4d97 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -628,24 +628,24 @@ class _RestoreWalletViewState extends ConsumerState { final results = AddressUtils.decodeQRSeedData(qrResult.rawContent); - Logging.instance.logd("scan parsed: $results", level: LogLevel.Info); - if (results["mnemonic"] != null) { final list = (results["mnemonic"] as List) .map((value) => value as String) .toList(growable: false); if (list.isNotEmpty) { _clearAndPopulateMnemonic(list); - Logging.instance.logd("mnemonic populated", level: LogLevel.Info); + Logging.instance.i("mnemonic populated"); } else { - Logging.instance - .logd("mnemonic failed to populate", level: LogLevel.Info); + Logging.instance.i("mnemonic failed to populate"); } } - } on PlatformException catch (e) { + } on PlatformException catch (e, s) { // likely failed to get camera permissions - Logging.instance - .logd("Restore wallet qr scan failed: $e", level: LogLevel.Warning); + Logging.instance.e( + "Restore wallet qr scan failed: $e", + error: e, + stackTrace: s, + ); } } diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart index 1f8952c15..7419583e7 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart @@ -73,11 +73,8 @@ class _RestoreFailedDialogState extends ConsumerState { ref.read(secureStoreProvider), ); } catch (e, s) { - Logging.instance.logd( - "Error while getting wallet info in restore failed dialog\n" - "Error: $e\nStack trace: $s", - level: LogLevel.Error, - ); + Logging.instance.e("Error while getting wallet info in restore failed dialog\n" + "Error: $e\nStack trace: $s"); } finally { if (mounted) { Navigator.of(context).pop(); diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart index 1f6177192..b1f5613bb 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart @@ -306,10 +306,7 @@ class _VerifyRecoveryPhraseViewState throw ex!; } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( diff --git a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart index dfe2155bd..f1f399f13 100644 --- a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart +++ b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart @@ -115,10 +115,7 @@ class _NewContactAddressEntryFormState // .read(shouldShowLockscreenOnResumeStateProvider // .state) // .state = true; - Logging.instance.logd( - "Failed to get camera permissions to scan address qr code: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("Failed to get camera permissions to scan address qr code: ", error: e, stackTrace: s); } } diff --git a/lib/pages/buy_view/buy_form.dart b/lib/pages/buy_view/buy_form.dart index 729e0e1c2..d68a02e4f 100644 --- a/lib/pages/buy_view/buy_form.dart +++ b/lib/pages/buy_view/buy_form.dart @@ -311,10 +311,7 @@ class _BuyFormState extends ConsumerState { .read(simplexProvider) .updateSupportedCryptos(response.value!); // TODO validate } else { - Logging.instance.logd( - "_loadSimplexCurrencies: $response", - level: LogLevel.Warning, - ); + Logging.instance.d("_loadSimplexCurrencies: $response"); } } @@ -326,10 +323,7 @@ class _BuyFormState extends ConsumerState { .read(simplexProvider) .updateSupportedFiats(response.value!); // TODO validate } else { - Logging.instance.logd( - "_loadSimplexCurrencies: $response", - level: LogLevel.Warning, - ); + Logging.instance.d("_loadSimplexCurrencies: $response"); } } @@ -626,10 +620,7 @@ class _BuyFormState extends ConsumerState { ref.read(simplexProvider).updateQuote(response.value!); return BuyResponse(value: response.value!); } else { - Logging.instance.logd( - "_loadQuote: $response", - level: LogLevel.Warning, - ); + Logging.instance.d("_loadQuote: $response"); return BuyResponse( exception: response.exception ?? BuyException( @@ -724,20 +715,14 @@ class _BuyFormState extends ConsumerState { final qrResult = await scanner.scan(); - Logging.instance.logd( - "qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult content: ${qrResult.rawContent}"); final paymentData = AddressUtils.parsePaymentUri( qrResult.rawContent, logging: Logging.instance, ); - Logging.instance.logd( - "qrResult parsed: $paymentData", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult parsed: $paymentData"); if (paymentData != null) { // auto fill address @@ -760,9 +745,10 @@ class _BuyFormState extends ConsumerState { } on PlatformException catch (e, s) { // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + Logging.instance.e( + "Failed to get camera permissions while trying to scan qr code in SendView: ", + error: e, + stackTrace: s, ); } } @@ -1241,7 +1227,11 @@ class _BuyFormState extends ConsumerState { } }); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Info); + Logging.instance.w( + "", + error: e, + stackTrace: s, + ); } }, ), diff --git a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart index 890ed2cd9..432a3435a 100644 --- a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart @@ -304,7 +304,7 @@ class CoinIconForTicker extends ConsumerWidget { height: size, ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Fatal); + Logging.instance.f("", error: e, stackTrace: s); rethrow; } } diff --git a/lib/pages/exchange_view/confirm_change_now_send.dart b/lib/pages/exchange_view/confirm_change_now_send.dart index 552b7f3a9..999fca764 100644 --- a/lib/pages/exchange_view/confirm_change_now_send.dart +++ b/lib/pages/exchange_view/confirm_change_now_send.dart @@ -162,10 +162,7 @@ class _ConfirmChangeNowSendViewState Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName)); } } catch (e, s) { - Logging.instance.logd( - "Broadcast transaction failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Broadcast transaction failed: ", error: e, stackTrace: s); // pop sending dialog Navigator.of(context).pop(); diff --git a/lib/pages/exchange_view/exchange_step_views/step_2_view.dart b/lib/pages/exchange_view/exchange_step_views/step_2_view.dart index b2873feb2..951c211b9 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_2_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_2_view.dart @@ -98,9 +98,10 @@ class _Step2ViewState extends ConsumerState { }); } } on PlatformException catch (e, s) { - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to get camera permissions while trying to scan qr code in SendView: ", + error: e, + stackTrace: s, ); } } @@ -135,9 +136,10 @@ class _Step2ViewState extends ConsumerState { }); } } on PlatformException catch (e, s) { - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to get camera permissions while trying to scan qr code in SendView: ", + error: e, + stackTrace: s, ); } } @@ -303,8 +305,11 @@ class _Step2ViewState extends ConsumerState { } }); } catch (e, s) { - Logging.instance - .logd("$e\n$s", level: LogLevel.Info); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); } }, ), @@ -543,9 +548,10 @@ class _Step2ViewState extends ConsumerState { }); }); } catch (e, s) { - Logging.instance.logd( + Logging.instance.i( "$e\n$s", - level: LogLevel.Info, + error: e, + stackTrace: s, ); } }, diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index 4196fb332..7b867aab3 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -317,7 +317,7 @@ class _Step4ViewState extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted && !wasCancelled) { // pop building dialog Navigator.of(context).pop(); diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index ec5778e30..59cf20a47 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -387,7 +387,7 @@ class _SendFromCardState extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted) { // pop building dialog Navigator.of(context).pop(); diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart index 1dc2ca237..ea91dc60f 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart @@ -173,9 +173,8 @@ class _ExchangeOptionState extends ConsumerState { ], ); } else { - Logging.instance.logd( + Logging.instance.w( "$runtimeType rate unavailable for ${widget.exchange.name}: $data", - level: LogLevel.Warning, ); return Consumer( diff --git a/lib/pages/paynym/subwidgets/paynym_followers_list.dart b/lib/pages/paynym/subwidgets/paynym_followers_list.dart index c362a5dba..857fc9c8a 100644 --- a/lib/pages/paynym/subwidgets/paynym_followers_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_followers_list.dart @@ -93,10 +93,11 @@ class _PaynymFollowersListState extends ConsumerState { ref.read(myPaynymAccountStateProvider.state).state = account.value!; } - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.w( "Failed pull down refresh of paynym home page: $e", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } }, diff --git a/lib/pages/paynym/subwidgets/paynym_following_list.dart b/lib/pages/paynym/subwidgets/paynym_following_list.dart index a1cda9b9a..9fa77cebf 100644 --- a/lib/pages/paynym/subwidgets/paynym_following_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_following_list.dart @@ -93,10 +93,11 @@ class _PaynymFollowingListState extends ConsumerState { ref.read(myPaynymAccountStateProvider.state).state = account.value!; } - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.w( "Failed pull down refresh of paynym home page: $e", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } }, diff --git a/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart b/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart index 9fc8adb41..7b02e525f 100644 --- a/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart +++ b/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart @@ -188,10 +188,7 @@ class _GenerateUriQrCodeViewState extends State { queryParams, ); - Logging.instance.logd( - "Generated receiving QR code for: $uriString", - level: LogLevel.Info, - ); + Logging.instance.d("Generated receiving QR code for: $uriString"); return uriString; } diff --git a/lib/pages/send_view/frost_ms/recipient.dart b/lib/pages/send_view/frost_ms/recipient.dart index 5820b7375..ba8b9dbd7 100644 --- a/lib/pages/send_view/frost_ms/recipient.dart +++ b/lib/pages/send_view/frost_ms/recipient.dart @@ -133,20 +133,14 @@ class _RecipientState extends ConsumerState { final qrResult = await ref.read(pBarcodeScanner).scan(); - Logging.instance.logd( - "qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult content: ${qrResult.rawContent}"); final paymentData = AddressUtils.parsePaymentUri( qrResult.rawContent, logging: Logging.instance, ); - Logging.instance.logd( - "qrResult parsed: $paymentData", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult parsed: $paymentData"); if (paymentData != null && paymentData.coin?.uriScheme == widget.coin.uriScheme) { @@ -175,10 +169,11 @@ class _RecipientState extends ConsumerState { _updateRecipientData(); } on PlatformException catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Failed to get camera permissions while " "trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } } diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart index 3bb7a9bd0..31eb7b4d4 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart @@ -67,10 +67,7 @@ class _FrostSendStep1aState extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); } finally { _attemptSignLock = false; } diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart index a67afe7d3..ade993b22 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart @@ -108,10 +108,7 @@ class _FrostSendStep1bState extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted) { await showDialog( context: context, diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart index 14bee2844..febae8b54 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart @@ -291,10 +291,7 @@ class _FrostSendStep2State extends ConsumerState { // arguments: widget.walletId, // ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (context.mounted) { return await showDialog( diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart index 0b8c79c8b..6ce475a0b 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart @@ -233,10 +233,7 @@ class _FrostSendStep3State extends ConsumerState { .routeName, ); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (context.mounted) { return await showDialog( diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart index ec9eb3e2a..ee45a6e70 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart @@ -237,10 +237,7 @@ class _FrostSendStep4State extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (context.mounted) { return await showDialog( context: context, diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index a3598fbe5..7d063ba6f 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -158,10 +158,7 @@ class _SendViewState extends ConsumerState { // .state = true, // ); - Logging.instance.logd( - "qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult content: ${qrResult.rawContent}"); final paymentData = AddressUtils.parsePaymentUri( qrResult.rawContent, @@ -216,9 +213,10 @@ class _SendViewState extends ConsumerState { // .state = true; // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + Logging.instance.e( + "Failed to get camera permissions while trying to scan qr code in SendView: ", + error: e, + stackTrace: s, ); } } @@ -248,8 +246,6 @@ class _SendViewState extends ConsumerState { return; } _cachedAmountToSend = amount; - Logging.instance.logd("it changed $amount $_cachedAmountToSend", - level: LogLevel.Info); final amountString = ref.read(pAmountFormatter(coin)).format( amount, @@ -285,16 +281,12 @@ class _SendViewState extends ConsumerState { return; } _cachedAmountToSend = amount; - Logging.instance.logd( - "it changed $amount $_cachedAmountToSend", - level: LogLevel.Info, - ); final price = ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1; if (price > Decimal.zero) { - baseAmountController.text = (amount!.decimal * price) + baseAmountController.text = (amount.decimal * price) .toAmount( fractionDigits: 2, ) @@ -314,9 +306,7 @@ class _SendViewState extends ConsumerState { if (coin is! Epiccash && !_baseFocus.hasFocus) { setState(() { _calculateFeesFuture = calculateFees( - amount == null - ? 0.toAmountAsRaw(fractionDigits: coin.fractionDigits) - : amount!, + amount ?? 0.toAmountAsRaw(fractionDigits: coin.fractionDigits), ); }); } @@ -369,7 +359,7 @@ class _SendViewState extends ConsumerState { } String? _updateInvalidAddressText(String address) { - if (_data != null && _data!.contactLabel == address) { + if (_data != null && _data.contactLabel == address) { return null; } @@ -695,9 +685,7 @@ class _SendViewState extends ConsumerState { ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, - utxos: (wallet is CoinControlInterface && - coinControlEnabled && - selectedUTXOs.isNotEmpty) + utxos: (coinControlEnabled && selectedUTXOs.isNotEmpty) ? selectedUTXOs : null, ), @@ -714,9 +702,7 @@ class _SendViewState extends ConsumerState { ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, - utxos: (wallet is CoinControlInterface && - coinControlEnabled && - selectedUTXOs.isNotEmpty) + utxos: (coinControlEnabled && selectedUTXOs.isNotEmpty) ? selectedUTXOs : null, ), @@ -828,7 +814,7 @@ class _SendViewState extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted) { // pop building dialog Navigator.of(context).pop(); @@ -960,9 +946,9 @@ class _SendViewState extends ConsumerState { baseAmountController.addListener(_baseAmountChanged); if (_data != null) { - if (_data!.amount != null) { + if (_data.amount != null) { final amount = Amount.fromDecimal( - _data!.amount!, + _data.amount!, fractionDigits: coin.fractionDigits, ); @@ -971,8 +957,8 @@ class _SendViewState extends ConsumerState { withUnitName: false, ); } - sendToController.text = _data!.contactLabel; - _address = _data!.address.trim(); + sendToController.text = _data.contactLabel; + _address = _data.address.trim(); _addressToggleFlag = true; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { @@ -1602,9 +1588,9 @@ class _SendViewState extends ConsumerState { ) == FiroType.lelantus) { if (_data != null && - _data!.contactLabel == _address) { + _data.contactLabel == _address) { error = SparkInterface.validateSparkAddress( - address: _data!.address, + address: _data.address, isTestNet: coin.network == CryptoCurrencyNetwork.test, ) @@ -1620,7 +1606,7 @@ class _SendViewState extends ConsumerState { } } else { if (_data != null && - _data!.contactLabel == _address) { + _data.contactLabel == _address) { error = null; } else if (!ref.watch(pValidSendToAddress) && !ref.watch(pValidSparkSendToAddress)) { @@ -1631,7 +1617,7 @@ class _SendViewState extends ConsumerState { } } else { if (_data != null && - _data!.contactLabel == _address) { + _data.contactLabel == _address) { error = null; } else if (!ref.watch(pValidSendToAddress)) { error = "Invalid address"; @@ -1815,7 +1801,9 @@ class _SendViewState extends ConsumerState { if (coin is! Ethereum && coin is! Tezos) CustomTextButton( text: _getSendAllTitle( - showCoinControl, selectedUTXOs), + showCoinControl, + selectedUTXOs, + ), onTap: () => _sendAllTapped(showCoinControl), ), ], diff --git a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart index e45026981..2586d88ee 100644 --- a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart @@ -831,7 +831,7 @@ class _TransactionFeeSelectionSheetState return null; } } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Warning); + Logging.instance.w("$e $s", error: e, stackTrace: s,); return null; } } diff --git a/lib/pages/send_view/token_send_view.dart b/lib/pages/send_view/token_send_view.dart index 112e15073..01ae07406 100644 --- a/lib/pages/send_view/token_send_view.dart +++ b/lib/pages/send_view/token_send_view.dart @@ -159,18 +159,14 @@ class _TokenSendViewState extends ConsumerState { // .state = true, // ); - Logging.instance.logd( - "qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult content: ${qrResult.rawContent}"); final paymentData = AddressUtils.parsePaymentUri( qrResult.rawContent, logging: Logging.instance, ); - Logging.instance - .logd("qrResult parsed: $paymentData", level: LogLevel.Info); + Logging.instance.d("qrResult parsed: $paymentData"); if (paymentData != null && paymentData.coin?.uriScheme == coin.uriScheme) { @@ -221,9 +217,10 @@ class _TokenSendViewState extends ConsumerState { // .state = true; // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to get camera permissions while trying to scan qr code in SendView: ", + error: e, + stackTrace: s, ); } } @@ -255,10 +252,6 @@ class _TokenSendViewState extends ConsumerState { return; } _cachedAmountToSend = _amountToSend; - Logging.instance.logd( - "it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info, - ); _cryptoAmountChangeLock = true; cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format( @@ -293,10 +286,6 @@ class _TokenSendViewState extends ConsumerState { return; } _cachedAmountToSend = _amountToSend; - Logging.instance.logd( - "it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info, - ); final price = ref .read(priceAnd24hChangeNotifierProvider) @@ -535,7 +524,7 @@ class _TokenSendViewState extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted) { // pop building dialog Navigator.of(context).pop(); diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart index b274ae093..5ef5821a2 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart @@ -55,10 +55,7 @@ class _InstallThemeFromFileDialogState ]); return true; } catch (e, s) { - Logging.instance.logd( - "Failed to install theme: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("Failed to install theme: ", error: e, stackTrace: s); return false; } } @@ -78,7 +75,7 @@ class _InstallThemeFromFileDialogState }); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); } } diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart index b9f991ab8..06cbfe852 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart @@ -64,10 +64,7 @@ class _StackThemeCardState extends ConsumerState { await service.install(themeArchiveData: data); return true; } catch (e, s) { - Logging.instance.logd( - "Failed _downloadAndInstall of ${widget.data.id}: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("Failed _downloadAndInstall of ${widget.data.id}: ", error: e, stackTrace: s); return false; } } diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart index d437c8a86..0f00f75db 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart @@ -351,34 +351,28 @@ class _AddEditNodeViewState extends ConsumerState { ); if (qrResult == null) { - Logging.instance.logd( - "Qr scanning cancelled", - level: LogLevel.Info, - ); + Logging.instance.d("Qr scanning cancelled"); } else { try { await _processQrData(qrResult); } catch (e, s) { - Logging.instance.logd( - "Error processing QR code data: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error processing QR code data: ", + error: e, stackTrace: s); } } } catch (e, s) { - Logging.instance.logd( - "Error opening QR code scanner dialog: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error opening QR code scanner dialog: ", + error: e, stackTrace: s); } } else { try { final result = await BarcodeScanner.scan(); await _processQrData(result.rawContent); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Warning, + Logging.instance.e( + "$runtimeType._scanQr()", + error: e, + stackTrace: s, ); } } @@ -412,9 +406,10 @@ class _AddEditNodeViewState extends ConsumerState { }); } } catch (e, s) { - Logging.instance.logd( + Logging.instance.w( "$e\n$s", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } } diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart index 228132010..c75ac4a83 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart @@ -175,8 +175,8 @@ class _EnableAutoBackupViewState extends ConsumerState { }); } } catch (e, s) { - Logging.instance.logd("$e\n$s", - level: LogLevel.Error); + Logging.instance + .e("$e\n$s", error: e, stackTrace: s); } }, controller: fileLocationController, @@ -578,8 +578,8 @@ class _EnableAutoBackupViewState extends ConsumerState { } on Exception catch (e, s) { final String err = getErrorMessageFromSWBException(e); - Logging.instance.logd("$err\n$s", - level: LogLevel.Error); + Logging.instance + .e("$err\n$s", error: e, stackTrace: s); // pop encryption progress dialog Navigator.of(context).pop(); showFloatingFlushBar( @@ -589,8 +589,11 @@ class _EnableAutoBackupViewState extends ConsumerState { ); return; } catch (e, s) { - Logging.instance - .logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); // pop encryption progress dialog Navigator.of(context).pop(); showFloatingFlushBar( diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart index b3c1a4369..944847a42 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart @@ -207,8 +207,11 @@ class _RestoreFromFileViewState extends State { }); } } catch (e, s) { - Logging.instance - .logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); } }, controller: fileLocationController, diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart index 61555ee23..53669d9f0 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart @@ -159,7 +159,7 @@ class _EditAutoBackupViewState extends ConsumerState { adkVersion = adk.item1; } on Exception catch (e, s) { final String err = getErrorMessageFromSWBException(e); - Logging.instance.logd("$err\n$s", level: LogLevel.Error); + Logging.instance.e("$err\n$s", error: e, stackTrace: s); // pop encryption progress dialog Navigator.of(context).pop(); unawaited( @@ -171,7 +171,7 @@ class _EditAutoBackupViewState extends ConsumerState { ); return; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); // pop encryption progress dialog Navigator.of(context).pop(); unawaited( @@ -374,7 +374,7 @@ class _EditAutoBackupViewState extends ConsumerState { }); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); } }, controller: fileLocationController, diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index 43d0160b6..935dad27b 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -99,12 +99,10 @@ abstract class SWB { _cancelCompleter = null; _cancelCompleter = Completer(); _shouldCancelRestore = true; - Logging.instance - .logd("SWB cancel restore requested", level: LogLevel.Info); + Logging.instance.d("SWB cancel restore requested"); } else { - Logging.instance.logd( + Logging.instance.d( "SWB cancel restore requested while a cancellation request is currently in progress", - level: LogLevel.Warning, ); } @@ -147,10 +145,10 @@ abstract class SWB { backupFile .writeAsStringSync(Format.uint8listToString(encryptedContent)); } - Logging.instance.logd(backupFile.absolute, level: LogLevel.Info); + Logging.instance.d(backupFile.absolute); return true; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); return false; } } @@ -174,10 +172,10 @@ abstract class SWB { backupFile .writeAsStringSync(Format.uint8listToString(encryptedContent)); } - Logging.instance.logd(backupFile.absolute, level: LogLevel.Info); + Logging.instance.d(backupFile.absolute); return true; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); return false; } } @@ -194,7 +192,7 @@ abstract class SWB { Tuple2(encryptedText, passphrase), ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); return null; } } @@ -214,7 +212,7 @@ abstract class SWB { final jsonBackup = utf8.decode(decryptedContent); return jsonBackup; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); return null; } } @@ -223,27 +221,23 @@ abstract class SWB { static Future> createStackWalletJSON({ required SecureStorageInterface secureStorage, }) async { - Logging.instance - .logd("Starting createStackWalletJSON...", level: LogLevel.Info); + Logging.instance.d("Starting createStackWalletJSON..."); final _wallets = Wallets.sharedInstance; final Map backupJson = {}; final NodeService nodeService = NodeService(secureStorageInterface: secureStorage); final _secureStore = secureStorage; - Logging.instance.logd( + Logging.instance.d( "createStackWalletJSON awaiting DB.instance.mutex...", - level: LogLevel.Info, ); // prevent modification of data await DB.instance.mutex.protect(() async { - Logging.instance.logd( + Logging.instance.i( "...createStackWalletJSON DB.instance.mutex acquired", - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.i( "SWB backing up nodes", - level: LogLevel.Warning, ); try { final primaryNodes = nodeService.primaryNodes.map((e) async { @@ -253,7 +247,11 @@ abstract class SWB { }).toList(); backupJson['primaryNodes'] = await Future.wait(primaryNodes); } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Warning); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); } try { final nodesFuture = nodeService.nodes.map((e) async { @@ -264,12 +262,11 @@ abstract class SWB { final nodes = await Future.wait(nodesFuture); backupJson['nodes'] = nodes; } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("", error: e, stackTrace: s); } - Logging.instance.logd( + Logging.instance.d( "SWB backing up prefs", - level: LogLevel.Warning, ); final Map prefs = {}; @@ -291,9 +288,8 @@ abstract class SWB { backupJson['prefs'] = prefs; - Logging.instance.logd( + Logging.instance.d( "SWB backing up addressbook", - level: LogLevel.Warning, ); final AddressBookService addressBookService = AddressBookService(); @@ -301,9 +297,8 @@ abstract class SWB { backupJson['addressBookEntries'] = addresses.map((e) => e.toMap()).toList(); - Logging.instance.logd( + Logging.instance.d( "SWB backing up wallets", - level: LogLevel.Warning, ); final List backupWallets = []; @@ -330,7 +325,7 @@ abstract class SWB { final String err = "${wallet.info.coin.identifier} wallet ${wallet.info.name} " "has null keys or config"; - Logging.instance.logd(err, level: LogLevel.Fatal); + Logging.instance.e(err); throw Exception(err); } //This case should never actually happen in practice unless the whole @@ -368,9 +363,8 @@ abstract class SWB { } backupJson['wallets'] = backupWallets; - Logging.instance.logd( + Logging.instance.d( "SWB backing up trades", - level: LogLevel.Warning, ); // back up trade history @@ -385,9 +379,8 @@ abstract class SWB { tradeTxidLookupDataService.all.map((e) => e.toMap()).toList(); backupJson["tradeTxidLookupData"] = lookupData; - Logging.instance.logd( + Logging.instance.d( "SWB backing up trade notes", - level: LogLevel.Warning, ); // back up trade notes @@ -395,9 +388,8 @@ abstract class SWB { final tradeNotes = tradeNotesService.all; backupJson["tradeNotes"] = tradeNotes; }); - Logging.instance.logd( + Logging.instance.d( "createStackWalletJSON DB.instance.mutex released", - level: LogLevel.Info, ); // // back up notifications data @@ -407,8 +399,7 @@ abstract class SWB { // .map((e) => e.toMap()) // .toList(growable: false); - Logging.instance - .logd("...createStackWalletJSON complete", level: LogLevel.Info); + Logging.instance.d("...createStackWalletJSON complete"); return backupJson; } @@ -590,9 +581,8 @@ abstract class SWB { await restoringFuture; - Logging.instance.logd( + Logging.instance.i( "SWB restored: ${info.walletId} ${info.name} ${info.coin.prettyName}", - level: LogLevel.Info, ); final currentAddress = await wallet.getCurrentReceivingAddress(); @@ -606,7 +596,11 @@ abstract class SWB { mnemonicPassphrase: mnemonicPassphrase, ); } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Warning); + Logging.instance.i( + "", + error: e, + stackTrace: s, + ); uiState?.update( walletId: info.walletId, restoringStatus: StackRestoringStatus.failed, @@ -640,18 +634,16 @@ abstract class SWB { uiState?.preferences = StackRestoringStatus.restoring; - Logging.instance.logd( + Logging.instance.d( "SWB restoring prefs", - level: LogLevel.Warning, ); await _restorePrefs(prefs); uiState?.preferences = StackRestoringStatus.success; uiState?.addressBook = StackRestoringStatus.restoring; - Logging.instance.logd( + Logging.instance.d( "SWB restoring addressbook", - level: LogLevel.Warning, ); if (addressBookEntries != null) { await _restoreAddressBook(addressBookEntries); @@ -660,9 +652,8 @@ abstract class SWB { uiState?.addressBook = StackRestoringStatus.success; uiState?.nodes = StackRestoringStatus.restoring; - Logging.instance.logd( + Logging.instance.d( "SWB restoring nodes", - level: LogLevel.Warning, ); await _restoreNodes( nodes, @@ -675,18 +666,16 @@ abstract class SWB { // restore trade history if (trades != null) { - Logging.instance.logd( + Logging.instance.d( "SWB restoring trades", - level: LogLevel.Warning, ); await _restoreTrades(trades); } // restore trade history lookup data for trades send from stack wallet if (tradeTxidLookupData != null) { - Logging.instance.logd( + Logging.instance.d( "SWB restoring trade look up data", - level: LogLevel.Warning, ); await _restoreTradesLookUpData(tradeTxidLookupData, oldToNewWalletIdMap); } @@ -694,9 +683,8 @@ abstract class SWB { // restore trade notes if (tradeNotes != null) { - Logging.instance.logd( + Logging.instance.d( "SWB restoring trade notes", - level: LogLevel.Warning, ); await _restoreTradesNotes(tradeNotes); } @@ -729,15 +717,13 @@ abstract class SWB { ) async { if (!Platform.isLinux) await WakelockPlus.enable(); - Logging.instance.logd( + Logging.instance.d( "SWB creating temp backup", - level: LogLevel.Warning, ); final preRestoreJSON = await createStackWalletJSON(secureStorage: secureStorageInterface); - Logging.instance.logd( + Logging.instance.d( "SWB temp backup created", - level: LogLevel.Warning, ); final List _currentWalletIds = await MainDB.instance.isar.walletInfo @@ -832,9 +818,10 @@ abstract class SWB { otherData = Map.from(data as Map); } } catch (e, s) { - Logging.instance.logd( - "SWB restore walletinfo otherdata error: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "SWB restore walletinfo otherdata error: ", + error: e, + stackTrace: s, ); } @@ -950,7 +937,9 @@ abstract class SWB { return false; } - Logging.instance.logd("done with SWB restore", level: LogLevel.Warning); + Logging.instance.d( + "done with SWB restore", + ); await Wallets.sharedInstance .loadAfterStackRestore(_prefs, uiState?.wallets ?? [], Util.isDesktop); @@ -1100,7 +1089,7 @@ abstract class SWB { node: nodeService.getNodeById(id: node['id'] as String)!, ); } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("", error: e, stackTrace: s); } } } @@ -1193,7 +1182,9 @@ abstract class SWB { _cancelCompleter!.complete(); _shouldCancelRestore = false; - Logging.instance.logd("Revert SWB complete", level: LogLevel.Info); + Logging.instance.d( + "Revert SWB complete", + ); } static Future _restorePrefs(Map prefs) async { @@ -1310,7 +1301,7 @@ abstract class SWB { node: nodeService.getNodeById(id: node['id'] as String)!, ); } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("", error: e, stackTrace: s); } } } @@ -1327,7 +1318,7 @@ abstract class SWB { exTx = ExchangeTransaction.fromJson(trades[i] as Map); } catch (e) { // unneeded log - // Logging.instance.log("$e\n$s", level: LogLevel.Warning); + // Logging.instance.log("$e\n$s", error: e, stackTrace: s,); } Trade trade; diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart index 1a73743ac..400e6e08d 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart @@ -172,7 +172,7 @@ class _RestoreFromFileViewState extends ConsumerState { }); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); } }, controller: fileLocationController, diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart index 7064dfa5a..2c7ddd71e 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart @@ -169,7 +169,7 @@ class _StackRestoreProgressViewState ref.read(secureStoreProvider), ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); } if (finished != null && finished && uiState.done) { diff --git a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart index 5f34b89fa..245937fdf 100644 --- a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart @@ -604,10 +604,7 @@ Future connectTor(WidgetRef ref, BuildContext context) async { // Toggle the useTor preference on success. ref.read(prefsChangeNotifierProvider).useTor = true; } catch (e, s) { - Logging.instance.logd( - "Error starting tor: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error starting tor: ", error: e, stackTrace: s); // TODO: show dialog with error message } } @@ -627,10 +624,7 @@ Future disconnectTor(WidgetRef ref, BuildContext context) async { // Toggle the useTor preference on success. ref.read(prefsChangeNotifierProvider).useTor = false; } catch (e, s) { - Logging.instance.logd( - "Error stopping tor: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error stopping tor: ", error: e, stackTrace: s); // TODO: show dialog with error message } } diff --git a/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart b/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart index efb5ce11a..afc48647d 100644 --- a/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart @@ -148,10 +148,7 @@ class _CompleteReshareConfigViewState ); } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); if (mounted) { await showDialog( context: context, diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart index 34628565f..da8c328bf 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart @@ -114,7 +114,7 @@ class _LelantusSettingsViewState extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted) { // show error await showDialog( diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index 70246ee93..11ebd1b82 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -219,7 +219,7 @@ class _TransactionDetailsViewState return address; } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); return address; } } diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart index 55ecb0cb0..2acb6b1a1 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart @@ -406,7 +406,7 @@ class _TransactionV2DetailsViewState return address; } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); return address; } } diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 4247e96da..d94e25d7a 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -1199,10 +1199,7 @@ class _WalletViewState extends ConsumerState { .read(paynymAPIProvider) .nym(code.toString()); - Logging.instance.logd( - "my nym account: $account", - level: LogLevel.Info, - ); + Logging.instance.d("my nym account: $account"); if (context.mounted) { Navigator.of(context).pop(); diff --git a/lib/pages_desktop_specific/coin_control/freeze_button.dart b/lib/pages_desktop_specific/coin_control/freeze_button.dart index 440a65fd8..b012b01ad 100644 --- a/lib/pages_desktop_specific/coin_control/freeze_button.dart +++ b/lib/pages_desktop_specific/coin_control/freeze_button.dart @@ -79,10 +79,7 @@ class _FreezeButtonState extends State { break; default: - Logging.instance.logd( - "Unknown utxo method name found in $runtimeType", - level: LogLevel.Fatal, - ); + Logging.instance.f("Unknown utxo method name found in $runtimeType"); return; } diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart index a7f096d22..fd7c72a23 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart @@ -83,7 +83,7 @@ class _DesktopStep2State extends ConsumerState { ref.read(desktopExchangeModelProvider)!.recipientAddress = info.item2; } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Info); + Logging.instance.i("$e\n$s", error: e, stackTrace: s,); } widget.enableNextChanged.call( @@ -116,7 +116,7 @@ class _DesktopStep2State extends ConsumerState { ref.read(desktopExchangeModelProvider)!.refundAddress = info.item2; } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Info); + Logging.instance.i("$e\n$s", error: e, stackTrace: s,); } widget.enableNextChanged.call( _next(), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index ddf4f14f6..c3a9964d4 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -150,25 +150,18 @@ class _DesktopSendState extends ConsumerState { builder: (context) => const QrCodeScannerDialog(), ); if (qrResult == null) { - Logging.instance.logd( - "Qr scanning cancelled", - level: LogLevel.Info, - ); + Logging.instance.w("Qr scanning cancelled"); } else { try { _processQrCodeData(qrResult); } catch (e, s) { - Logging.instance.logd( - "Error processing QR code data: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Error processing QR code data", error: e, stackTrace: s); } } } catch (e, s) { - Logging.instance.logd( - "Error opening QR code scanner dialog: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Error opening QR code scanner dialog", error: e, stackTrace: s); } } @@ -513,7 +506,7 @@ class _DesktopSendState extends ConsumerState { ); } } catch (e, s) { - Logging.instance.logd("Desktop send: $e\n$s", level: LogLevel.Error); + Logging.instance.e("Desktop send: ", error: e, stackTrace: s); if (mounted) { // pop building dialog Navigator.of( @@ -618,17 +611,14 @@ class _DesktopSendState extends ConsumerState { if (_cachedAmountToSend != null && _cachedAmountToSend == amount) { return; } - Logging.instance.logd( - "it changed $amount $_cachedAmountToSend", - level: LogLevel.Info, - ); + _cachedAmountToSend = amount; final price = ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1; if (price > Decimal.zero) { - final String fiatAmountString = (amount!.decimal * price) + final String fiatAmountString = (amount.decimal * price) .toAmount(fractionDigits: 2) .fiatString( locale: ref.read(localeServiceChangeNotifierProvider).locale, @@ -707,8 +697,11 @@ class _DesktopSendState extends ConsumerState { }); } } catch (e, s) { - Logging.instance - .logd("Error processing QR code data: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "Error processing QR code data", + error: e, + stackTrace: s, + ); } } @@ -858,11 +851,9 @@ class _DesktopSendState extends ConsumerState { return; } _cachedAmountToSend = amount; - Logging.instance.logd("it changed $amount $_cachedAmountToSend", - level: LogLevel.Info); final amountString = ref.read(pAmountFormatter(coin)).format( - amount!, + amount, withUnitName: false, ); @@ -962,11 +953,11 @@ class _DesktopSendState extends ConsumerState { cryptoAmountController.addListener(onCryptoAmountChanged); if (_data != null) { - if (_data!.amount != null) { - cryptoAmountController.text = _data!.amount!.toString(); + if (_data.amount != null) { + cryptoAmountController.text = _data.amount!.toString(); } - sendToController.text = _data!.contactLabel; - _address = _data!.address; + sendToController.text = _data.contactLabel; + _address = _data.address; _addressToggleFlag = true; } @@ -1586,9 +1577,9 @@ class _DesktopSendState extends ConsumerState { error = null; } else if (coin is Firo) { if (firoType == FiroType.lelantus) { - if (_data != null && _data!.contactLabel == _address) { + if (_data != null && _data.contactLabel == _address) { error = SparkInterface.validateSparkAddress( - address: _data!.address, + address: _data.address, isTestNet: coin.network.isTestNet, ) ? "Lelantus to Spark not supported" @@ -1601,7 +1592,7 @@ class _DesktopSendState extends ConsumerState { : "Invalid address"; } } else { - if (_data != null && _data!.contactLabel == _address) { + if (_data != null && _data.contactLabel == _address) { error = null; } else if (!ref.watch(pValidSendToAddress) && !ref.watch(pValidSparkSendToAddress)) { @@ -1611,7 +1602,7 @@ class _DesktopSendState extends ConsumerState { } } } else { - if (_data != null && _data!.contactLabel == _address) { + if (_data != null && _data.contactLabel == _address) { error = null; } else if (!ref.watch(pValidSendToAddress)) { error = "Invalid address"; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart index 43d3c23a5..647b1e1cc 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart @@ -406,10 +406,6 @@ class _DesktopTokenSendState extends ConsumerState { _cachedAmountToSend == _amountToSend) { return; } - Logging.instance.logd( - "it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info, - ); _cachedAmountToSend = _amountToSend; final price = ref @@ -471,18 +467,14 @@ class _DesktopTokenSendState extends ConsumerState { final qrResult = await scanner.scan(); - Logging.instance.logd( - "qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info, - ); + Logging.instance.d("qrResult content: ${qrResult.rawContent}"); final paymentData = AddressUtils.parsePaymentUri( qrResult.rawContent, logging: Logging.instance, ); - Logging.instance - .logd("qrResult parsed: $paymentData", level: LogLevel.Info); + Logging.instance.d("qrResult parsed: $paymentData"); if (paymentData != null && paymentData.coin?.uriScheme == coin.uriScheme) { @@ -529,9 +521,10 @@ class _DesktopTokenSendState extends ConsumerState { } on PlatformException catch (e, s) { // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to get camera permissions while trying to scan qr code in SendView: ", + error: e, + stackTrace: s, ); } } @@ -586,10 +579,6 @@ class _DesktopTokenSendState extends ConsumerState { return; } _cachedAmountToSend = _amountToSend; - Logging.instance.logd( - "it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info, - ); final amountString = ref.read(pAmountFormatter(coin)).format( _amountToSend!, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index 2d874fffd..7993ee0a6 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -319,10 +319,7 @@ class _DesktopWalletFeaturesState extends ConsumerState { final account = await ref.read(paynymAPIProvider).nym(code.toString()); - Logging.instance.logd( - "my nym account: $account", - level: LogLevel.Info, - ); + Logging.instance.d("my nym account: $account"); if (mounted) { Navigator.of(context, rootNavigator: true).pop(); diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart index 38e91701c..eb2746558 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart @@ -213,7 +213,7 @@ class _MoreFeaturesDialogState extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); if (mounted) { // show error await showDialog( diff --git a/lib/pages_desktop_specific/password/delete_password_warning_view.dart b/lib/pages_desktop_specific/password/delete_password_warning_view.dart index 1b6c3d5b1..1eb1331a7 100644 --- a/lib/pages_desktop_specific/password/delete_password_warning_view.dart +++ b/lib/pages_desktop_specific/password/delete_password_warning_view.dart @@ -87,10 +87,7 @@ class _ForgotPasswordDesktopViewState await DB.instance.init(); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("$e\n$s", error: e, stackTrace: s,); return false; } diff --git a/lib/pages_desktop_specific/password/desktop_login_view.dart b/lib/pages_desktop_specific/password/desktop_login_view.dart index 04fab5bac..15b795278 100644 --- a/lib/pages_desktop_specific/password/desktop_login_view.dart +++ b/lib/pages_desktop_specific/password/desktop_login_view.dart @@ -75,10 +75,10 @@ class _DesktopLoginViewState extends ConsumerState { secureStore: ref.read(secureStoreProvider), ); } catch (e, s) { - Logging.instance.logd( - "Cannot migrate desktop database\n$e $s", - level: LogLevel.Error, - printFullLength: true, + Logging.instance.f( + "Cannot migrate desktop database", + error: e, + stackTrace: s, ); } } diff --git a/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart b/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart index 4030e6c50..161459e43 100644 --- a/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart +++ b/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart @@ -271,7 +271,7 @@ class _ForgottenPassphraseRestoreFromSWBState }); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); } }, child: MouseRegion( diff --git a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart index 3ad0f0f1f..94ce0da9d 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart @@ -57,10 +57,7 @@ class _DesktopInstallThemeState extends ConsumerState { ]); return true; } catch (e, s) { - Logging.instance.logd( - "Failed to install theme: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("Failed to install theme: ", error: e, stackTrace: s); return false; } } @@ -82,7 +79,7 @@ class _DesktopInstallThemeState extends ConsumerState { } } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); } } diff --git a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart index 3ed9aafc2..3ffea6508 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart @@ -201,8 +201,11 @@ class _CreateAutoBackup extends ConsumerState { }); } } catch (e, s) { - Logging.instance - .logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); } }, controller: fileLocationController, @@ -699,8 +702,11 @@ class _CreateAutoBackup extends ConsumerState { } on Exception catch (e, s) { final String err = getErrorMessageFromSWBException(e); - Logging.instance - .logd("$err\n$s", level: LogLevel.Error); + Logging.instance.e( + err, + error: e, + stackTrace: s, + ); // pop encryption progress dialog Navigator.of(context).pop(); unawaited( @@ -712,8 +718,11 @@ class _CreateAutoBackup extends ConsumerState { ); return; } catch (e, s) { - Logging.instance - .logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); // pop encryption progress dialog Navigator.of(context).pop(); unawaited( diff --git a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart index 6b698048a..162ed9860 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart @@ -71,10 +71,7 @@ class _TorSettingsState extends ConsumerState { // Toggle the useTor preference on success. ref.read(prefsChangeNotifierProvider).useTor = true; } catch (e, s) { - Logging.instance.logd( - "Error starting tor: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error starting tor: ", error: e, stackTrace: s); // TODO: show dialog with error message } }, @@ -101,10 +98,7 @@ class _TorSettingsState extends ConsumerState { // Toggle the useTor preference on success. ref.read(prefsChangeNotifierProvider).useTor = false; } catch (e, s) { - Logging.instance.logd( - "Error stopping tor: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error stopping tor: ", error: e, stackTrace: s); } }, ); diff --git a/lib/services/auto_swb_service.dart b/lib/services/auto_swb_service.dart index 4a44dfae3..24f58d0f7 100644 --- a/lib/services/auto_swb_service.dart +++ b/lib/services/auto_swb_service.dart @@ -42,14 +42,12 @@ class AutoSWBService extends ChangeNotifier { /// Attempt a backup. Future doBackup() async { if (_status == AutoSWBStatus.backingUp) { - Logging.instance.logd( + Logging.instance.w( "AutoSWBService attempted to run doBackup() while a backup is in progress!", - level: LogLevel.Warning, ); return; } - Logging.instance - .logd("AutoSWBService.doBackup() started...", level: LogLevel.Info); + Logging.instance.d("AutoSWBService.doBackup() started..."); // set running backup status and notify listeners _status = AutoSWBStatus.backingUp; @@ -62,9 +60,8 @@ class AutoSWBService extends ChangeNotifier { final autoBackupDirectoryPath = Prefs.instance.autoBackupLocation; if (autoBackupDirectoryPath == null) { - Logging.instance.logd( + Logging.instance.e( "AutoSWBService attempted to run doBackup() when no auto backup directory was set!", - level: LogLevel.Error, ); // set error backup status and notify listeners _status = AutoSWBStatus.error; @@ -104,17 +101,16 @@ class AutoSWBService extends ChangeNotifier { // delete all but the latest 3 auto backups trimBackups(autoBackupDirectoryPath, 3); - Logging.instance - .logd("AutoSWBService.doBackup() succeeded", level: LogLevel.Info); + Logging.instance.d("AutoSWBService.doBackup() succeeded"); } on Exception catch (e, s) { final String err = getErrorMessageFromSWBException(e); - Logging.instance.logd("$err\n$s", level: LogLevel.Error); + Logging.instance.e("$err\n$s", error: e, stackTrace: s); // set error backup status and notify listeners _status = AutoSWBStatus.error; notifyListeners(); return; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); // set error backup status and notify listeners _status = AutoSWBStatus.error; notifyListeners(); diff --git a/lib/services/buy/simplex/simplex_api.dart b/lib/services/buy/simplex/simplex_api.dart index 7242ee295..eed33ea1b 100644 --- a/lib/services/buy/simplex/simplex_api.dart +++ b/lib/services/buy/simplex/simplex_api.dart @@ -72,9 +72,10 @@ class SimplexAPI { return _parseSupportedCryptos(jsonArray); } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableCurrencies exception: ", + error: e, + stackTrace: s, ); return BuyResponse( exception: BuyException( @@ -106,8 +107,11 @@ class SimplexAPI { return BuyResponse(value: cryptos); } catch (e, s) { - Logging.instance - .logd("_parseSupported exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_parseSupported exception", + error: e, + stackTrace: s, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -143,10 +147,8 @@ class SimplexAPI { return _parseSupportedFiats(jsonArray); } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("getAvailableCurrencies exception: ", error: e, stackTrace: s); return BuyResponse( exception: BuyException( e.toString(), @@ -179,8 +181,11 @@ class SimplexAPI { return BuyResponse(value: fiats); } catch (e, s) { - Logging.instance - .logd("_parseSupported exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_parseSupported exception", + error: e, + stackTrace: s, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -236,8 +241,11 @@ class SimplexAPI { return _parseQuote(jsonArray); } catch (e, s) { - Logging.instance - .logd("getQuote exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getQuote exception", + error: e, + stackTrace: s, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -281,8 +289,11 @@ class SimplexAPI { return BuyResponse(value: _quote); } catch (e, s) { - Logging.instance - .logd("_parseQuote exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_parseQuote exception", + error: e, + stackTrace: s, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -351,8 +362,11 @@ class SimplexAPI { return BuyResponse(value: _order); } catch (e, s) { - Logging.instance - .logd("newOrder exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "newOrder exception", + error: e, + stackTrace: s, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -380,8 +394,11 @@ class SimplexAPI { return BuyResponse(value: status); } catch (e, s) { - Logging.instance - .logd("newOrder exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "newOrder exception", + error: e, + stackTrace: s, + ); return BuyResponse( exception: BuyException( e.toString(), diff --git a/lib/services/coins/tezos/api/tezos_api.dart b/lib/services/coins/tezos/api/tezos_api.dart index 776e0e700..6c2193577 100644 --- a/lib/services/coins/tezos/api/tezos_api.dart +++ b/lib/services/coins/tezos/api/tezos_api.dart @@ -25,10 +25,7 @@ abstract final class TezosAPI { final result = jsonDecode(response.body); return result as int; } catch (e, s) { - Logging.instance.logd( - "Error occurred in TezosAPI while getting counter for $address: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in TezosAPI while getting counter for $address: ", error: e, stackTrace: s); rethrow; } } @@ -53,10 +50,7 @@ abstract final class TezosAPI { return account; } catch (e, s) { - Logging.instance.logd( - "Error occurred in TezosAPI while getting account for $address: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in TezosAPI while getting account for $address: ", error: e, stackTrace: s); rethrow; } } @@ -109,10 +103,7 @@ abstract final class TezosAPI { } return txs; } catch (e, s) { - Logging.instance.logd( - "Error occurred in TezosAPI while getting transactions for $address: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in TezosAPI while getting transactions for $address: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/services/coins/tezos/api/tezos_rpc_api.dart b/lib/services/coins/tezos/api/tezos_rpc_api.dart index afddfa4c3..688d9f68e 100644 --- a/lib/services/coins/tezos/api/tezos_rpc_api.dart +++ b/lib/services/coins/tezos/api/tezos_rpc_api.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import '../../../../networking/http.dart'; -import '../../../tor_service.dart'; import '../../../../utilities/logger.dart'; import '../../../../utilities/prefs.dart'; +import '../../../tor_service.dart'; abstract final class TezosRpcAPI { static final HTTP _client = HTTP(); @@ -27,10 +27,11 @@ abstract final class TezosRpcAPI { final balance = BigInt.parse(response.body.substring(1, response.body.length - 2)); return balance; - } catch (e) { - Logging.instance.logd( - "Error occurred in tezos_rpc_api.dart while getting balance for $address: $e", - level: LogLevel.Error, + } catch (e, s) { + Logging.instance.e( + "Error occurred in tezos_rpc_api.dart while getting balance for $address", + error: e, + stackTrace: s, ); } return null; @@ -53,10 +54,11 @@ abstract final class TezosRpcAPI { final jsonParsedResponse = jsonDecode(response.body); return int.parse(jsonParsedResponse["level"].toString()); - } catch (e) { - Logging.instance.logd( - "Error occurred in tezos_rpc_api.dart while getting chain height for tezos: $e", - level: LogLevel.Error, + } catch (e, s) { + Logging.instance.e( + "Error occurred in tezos_rpc_api.dart while getting chain height for tezos", + error: e, + stackTrace: s, ); } return null; diff --git a/lib/services/ethereum/cached_eth_token_balance.dart b/lib/services/ethereum/cached_eth_token_balance.dart index 7841a7580..ce6efe1b4 100644 --- a/lib/services/ethereum/cached_eth_token_balance.dart +++ b/lib/services/ethereum/cached_eth_token_balance.dart @@ -9,13 +9,14 @@ */ import 'package:isar/isar.dart'; + import '../../db/isar/main_db.dart'; import '../../models/balance.dart'; import '../../models/isar/models/ethereum/eth_contract.dart'; -import 'ethereum_api.dart'; import '../../utilities/amount/amount.dart'; import '../../utilities/logger.dart'; import '../../wallets/isar/models/token_wallet_info.dart'; +import 'ethereum_api.dart'; class CachedEthTokenBalance { final String walletId; @@ -54,9 +55,8 @@ class CachedEthTokenBalance { isar: mainDB.isar, ); } else { - Logging.instance.logd( + Logging.instance.w( "CachedEthTokenBalance.fetchAndUpdateCachedBalance failed: ${response.exception}", - level: LogLevel.Warning, ); } } diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index fbfbe52fa..fccce0ceb 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -104,9 +104,11 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getEthTransactions($address): $e\n$s", - level: LogLevel.Error, + Logging.instance.e("getEthTransactions()", error: e); + Logging.instance.d( + "getEthTransactions($address)", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -170,9 +172,14 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getEthTransactionByHash($txid): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getEthTransactionByHash()", + error: e, + ); + Logging.instance.d( + "getEthTransactionByHash($txid)", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -233,9 +240,14 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getEthTransactionNonces($txns): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getEthTransactionNonces()", + error: e, + ); + Logging.instance.d( + "getEthTransactionNonces($txns)", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -291,9 +303,14 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getEthTokenTransactionsByTxids($txids): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getEthTokenTransactionsByTxids()", + error: e, + ); + Logging.instance.d( + "getEthTokenTransactionsByTxids($txids)", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -352,9 +369,14 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getTokenTransactions($address, $tokenContractAddress): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getTokenTransactions()", + error: e, + ); + Logging.instance.d( + "getTokenTransactions($address, $tokenContractAddress)", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -478,9 +500,10 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getWalletTokenBalance(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getWalletTokenBalance()", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -529,9 +552,10 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getAddressNonce(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAddressNonce()", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -585,9 +609,10 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getGasOracle(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getGasOracle()", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -643,17 +668,15 @@ abstract class EthereumAPI { if (json["data"] is List) { if ((json["data"] as List).isEmpty) { if (autoNameOnEmpty) { - Logging.instance.logd( + Logging.instance.d( "getTokenByContractAddress(): Adding token data to server", - level: LogLevel.Debug, ); // this will add the missing data to server await _addContractInfoToServer(contractAddress); - Logging.instance.logd( + Logging.instance.d( "getTokenByContractAddress(): Adding to server threw so now" "we try a normal fetch again", - level: LogLevel.Debug, ); // now try again @@ -709,9 +732,10 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getTokenByContractAddress(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getTokenByContractAddress()", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -753,9 +777,10 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getTokenAbi($name, $contractAddress): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getTokenAbi($name, $contractAddress)", + error: e, + stackTrace: s, ); return EthereumResponse( null, @@ -798,9 +823,10 @@ abstract class EthereumAPI { e, ); } catch (e, s) { - Logging.instance.logd( - "getProxyTokenImplementationAddress($contractAddress) : $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getProxyTokenImplementationAddress($contractAddress)", + error: e, + stackTrace: s, ); return EthereumResponse( null, diff --git a/lib/services/event_bus/events/global/balance_refreshed_event.dart b/lib/services/event_bus/events/global/balance_refreshed_event.dart index d061a5e3e..90e81a0e5 100644 --- a/lib/services/event_bus/events/global/balance_refreshed_event.dart +++ b/lib/services/event_bus/events/global/balance_refreshed_event.dart @@ -14,9 +14,6 @@ class BalanceRefreshedEvent { final String walletId; BalanceRefreshedEvent(this.walletId) { - Logging.instance.logd( - "BalanceRefreshedEvent fired on $walletId", - level: LogLevel.Info, - ); + Logging.instance.d("BalanceRefreshedEvent fired on $walletId"); } } diff --git a/lib/services/event_bus/events/global/blocks_remaining_event.dart b/lib/services/event_bus/events/global/blocks_remaining_event.dart index f94fc0b23..ec8b968f0 100644 --- a/lib/services/event_bus/events/global/blocks_remaining_event.dart +++ b/lib/services/event_bus/events/global/blocks_remaining_event.dart @@ -15,9 +15,7 @@ class BlocksRemainingEvent { String walletId; BlocksRemainingEvent(this.blocksRemaining, this.walletId) { - Logging.instance.logd( - "RefreshPercentChangedEvent fired on $walletId with blocks remaining = $blocksRemaining", - level: LogLevel.Info, - ); + Logging.instance.d( + "RefreshPercentChangedEvent fired on $walletId with blocks remaining = $blocksRemaining"); } } diff --git a/lib/services/event_bus/events/global/node_connection_status_changed_event.dart b/lib/services/event_bus/events/global/node_connection_status_changed_event.dart index 9f60bc9db..202c2287d 100644 --- a/lib/services/event_bus/events/global/node_connection_status_changed_event.dart +++ b/lib/services/event_bus/events/global/node_connection_status_changed_event.dart @@ -19,9 +19,8 @@ class NodeConnectionStatusChangedEvent { CryptoCurrency coin; NodeConnectionStatusChangedEvent(this.newStatus, this.walletId, this.coin) { - Logging.instance.logd( + Logging.instance.d( "NodeConnectionStatusChangedEvent fired in $walletId with arg newStatus = $newStatus", - level: LogLevel.Info, ); } } diff --git a/lib/services/event_bus/events/global/refresh_percent_changed_event.dart b/lib/services/event_bus/events/global/refresh_percent_changed_event.dart index fcae085b3..2bd9ffe27 100644 --- a/lib/services/event_bus/events/global/refresh_percent_changed_event.dart +++ b/lib/services/event_bus/events/global/refresh_percent_changed_event.dart @@ -15,9 +15,7 @@ class RefreshPercentChangedEvent { String walletId; RefreshPercentChangedEvent(this.percent, this.walletId) { - Logging.instance.logd( - "RefreshPercentChangedEvent fired on $walletId with percent (range of 0.0-1.0)= $percent", - level: LogLevel.Info, - ); + Logging.instance.d( + "RefreshPercentChangedEvent fired on $walletId with percent (range of 0.0-1.0)= $percent"); } } diff --git a/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart b/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart index e42991270..6d7818c32 100644 --- a/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart +++ b/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart @@ -16,9 +16,7 @@ class TorConnectionStatusChangedEvent { String message = ""; TorConnectionStatusChangedEvent(this.newStatus, this.message) { - Logging.instance.logd( - "TorSyncStatusChangedEvent fired with arg newStatus = $newStatus ($message)", - level: LogLevel.Info, - ); + Logging.instance.d( + "TorSyncStatusChangedEvent fired with arg newStatus = $newStatus ($message)"); } } diff --git a/lib/services/event_bus/events/global/tor_status_changed_event.dart b/lib/services/event_bus/events/global/tor_status_changed_event.dart index 2466f4225..55147f0b1 100644 --- a/lib/services/event_bus/events/global/tor_status_changed_event.dart +++ b/lib/services/event_bus/events/global/tor_status_changed_event.dart @@ -20,9 +20,7 @@ class TorPreferenceChangedEvent { required this.status, this.message, }) { - Logging.instance.logd( - "TorStatusChangedEvent changed to \"$status\" with message: $message", - level: LogLevel.Warning, - ); + Logging.instance.w( + "TorStatusChangedEvent changed to \"$status\" with message: $message"); } } diff --git a/lib/services/event_bus/events/global/updated_in_background_event.dart b/lib/services/event_bus/events/global/updated_in_background_event.dart index 94ad3a3da..88089e810 100644 --- a/lib/services/event_bus/events/global/updated_in_background_event.dart +++ b/lib/services/event_bus/events/global/updated_in_background_event.dart @@ -8,8 +8,6 @@ * */ -import 'package:flutter/foundation.dart'; - import '../../../../utilities/logger.dart'; class UpdatedInBackgroundEvent { @@ -17,11 +15,8 @@ class UpdatedInBackgroundEvent { String walletId; UpdatedInBackgroundEvent(this.message, this.walletId) { - if (kDebugMode) { - Logging.instance.logd( - "UpdatedInBackgroundEvent fired with message: $message", - level: LogLevel.Info, - ); - } + Logging.instance.d( + "UpdatedInBackgroundEvent fired with message: $message", + ); } } diff --git a/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart b/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart index 497e6a97d..0fc07a993 100644 --- a/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart +++ b/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart @@ -19,9 +19,7 @@ class WalletSyncStatusChangedEvent { CryptoCurrency coin; WalletSyncStatusChangedEvent(this.newStatus, this.walletId, this.coin) { - Logging.instance.logd( - "WalletSyncStatusChangedEvent fired in $walletId with arg newStatus = $newStatus", - level: LogLevel.Info, - ); + Logging.instance.d( + "WalletSyncStatusChangedEvent fired in $walletId with arg newStatus = $newStatus"); } } diff --git a/lib/services/exchange/change_now/change_now_api.dart b/lib/services/exchange/change_now/change_now_api.dart index e0b96bf3b..d7cf255d5 100644 --- a/lib/services/exchange/change_now/change_now_api.dart +++ b/lib/services/exchange/change_now/change_now_api.dart @@ -78,8 +78,11 @@ class ChangeNowAPI { }; } } catch (e, s) { - Logging.instance - .logd("_makeRequest($uri) threw: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_makeRequest($uri) threw", + error: e, + stackTrace: s, + ); rethrow; } } @@ -102,8 +105,11 @@ class ChangeNowAPI { return parsed; } catch (e, s) { - Logging.instance - .logd("_makeRequestV2($uri) threw: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_makeRequestV2($uri) threw", + error: e, + stackTrace: s, + ); rethrow; } } @@ -128,14 +134,20 @@ class ChangeNowAPI { final parsed = jsonDecode(data); return parsed; - } catch (_) { - Logging.instance.logd("ChangeNOW api failed to parse: $data", - level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + "ChangeNOW api failed to parse: $data", + error: e, + stackTrace: s, + ); rethrow; } } catch (e, s) { - Logging.instance - .logd("_makePostRequest($uri) threw: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_makePostRequest($uri) threw", + error: e, + stackTrace: s, + ); rethrow; } } @@ -173,9 +185,10 @@ class ChangeNowAPI { ); return result; } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableCurrencies exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -185,9 +198,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableCurrencies exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -263,9 +277,10 @@ class ChangeNowAPI { ); return result; } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableCurrencies exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -275,9 +290,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableCurrencies exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -381,9 +397,10 @@ class ChangeNowAPI { } } } catch (e, s) { - Logging.instance.logd( - "getPairedCurrencies exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getPairedCurrencies exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -394,8 +411,11 @@ class ChangeNowAPI { } return ExchangeResponse(value: currencies); } catch (e, s) { - Logging.instance - .logd("getPairedCurrencies exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getPairedCurrencies exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -435,9 +455,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getMinimalExchangeAmount exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getMinimalExchangeAmount exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -478,9 +499,10 @@ class ChangeNowAPI { ), ); } catch (e, s) { - Logging.instance.logd( - "getRange exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getRange exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -551,9 +573,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getEstimatedExchangeAmount exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getEstimatedExchangeAmount exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -637,9 +660,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getEstimatedExchangeAmount exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getEstimatedExchangeAmount exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -763,9 +787,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getEstimatedExchangeAmountV2 exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getEstimatedExchangeAmountV2 exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -797,9 +822,10 @@ class ChangeNowAPI { await compute(_parseFixedRateMarketsJson, jsonArray as List); return result; } catch (e, s) { - Logging.instance.logd( - "getAvailableFixedRateMarkets exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableFixedRateMarkets exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -809,9 +835,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getAvailableFixedRateMarkets exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableFixedRateMarkets exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -898,9 +925,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "createStandardExchangeTransaction exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "createStandardExchangeTransaction exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -973,9 +1001,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "createFixedRateExchangeTransaction exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "createFixedRateExchangeTransaction exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -1011,8 +1040,11 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd("getTransactionStatus exception: $e\n$s", - level: LogLevel.Error); + Logging.instance.e( + "getTransactionStatus exception: ", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -1041,9 +1073,10 @@ class ChangeNowAPI { ); return result; } catch (e, s) { - Logging.instance.logd( - "getAvailableFloatingRatePairs exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableFloatingRatePairs exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -1053,9 +1086,10 @@ class ChangeNowAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getAvailableFloatingRatePairs exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableFloatingRatePairs exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( diff --git a/lib/services/exchange/exchange_data_loading_service.dart b/lib/services/exchange/exchange_data_loading_service.dart index 1708a1413..1cfaee23b 100644 --- a/lib/services/exchange/exchange_data_loading_service.dart +++ b/lib/services/exchange/exchange_data_loading_service.dart @@ -145,9 +145,8 @@ class ExchangeDataLoadingService { if (_isar == null) { await initDB(); } - Logging.instance.logd( + Logging.instance.d( "ExchangeDataLoadingService.loadAll starting...", - level: LogLevel.Info, ); final start = DateTime.now(); try { @@ -185,16 +184,16 @@ class ExchangeDataLoadingService { // wait for all loading futures to complete await Future.wait(futures); - Logging.instance.logd( + Logging.instance.d( "ExchangeDataLoadingService.loadAll finished in ${DateTime.now().difference(start).inSeconds} seconds", - level: LogLevel.Info, ); onLoadingComplete?.call(); await _updateCurrentCacheVersion(cacheVersion); } catch (e, s) { - Logging.instance.logd( - "ExchangeDataLoadingService.loadAll failed after ${DateTime.now().difference(start).inSeconds} seconds: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "ExchangeDataLoadingService.loadAll failed after ${DateTime.now().difference(start).inSeconds} seconds: ", + error: e, + stackTrace: s, ); onLoadingError?.call(); } @@ -219,9 +218,8 @@ class ExchangeDataLoadingService { await isar.currencies.putAll(responseCurrencies.value!); }); } else { - Logging.instance.logd( + Logging.instance.w( "Failed to load changeNOW currencies: ${responseCurrencies.exception?.message}", - level: LogLevel.Error, ); return; } @@ -353,9 +351,8 @@ class ExchangeDataLoadingService { await isar.currencies.putAll(responseCurrencies.value!); }); } else { - Logging.instance.logd( + Logging.instance.w( "loadMajesticBankCurrencies: $responseCurrencies", - level: LogLevel.Warning, ); } } @@ -378,9 +375,8 @@ class ExchangeDataLoadingService { await isar.currencies.putAll(responseCurrencies.value!); }); } else { - Logging.instance.logd( + Logging.instance.w( "loadTrocadorCurrencies: $responseCurrencies", - level: LogLevel.Warning, ); } } @@ -403,9 +399,8 @@ class ExchangeDataLoadingService { await isar.currencies.putAll(responseCurrencies.value!); }); } else { - Logging.instance.logd( + Logging.instance.w( "loadNanswapCurrencies: $responseCurrencies", - level: LogLevel.Warning, ); } } diff --git a/lib/services/exchange/majestic_bank/majestic_bank_api.dart b/lib/services/exchange/majestic_bank/majestic_bank_api.dart index 5f64112c2..210be8af4 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_api.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_api.dart @@ -61,10 +61,8 @@ class MajesticBankAPI { return parsed; } catch (e, s) { - Logging.instance.logd( - "_makeRequest($uri) HTTP:$code threw: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("_makeRequest($uri) HTTP:$code threw: ", error: e, stackTrace: s); rethrow; } } @@ -92,8 +90,11 @@ class MajesticBankAPI { } return ExchangeResponse(value: rates); } catch (e, s) { - Logging.instance - .logd("getRates exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getRates exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -126,8 +127,11 @@ class MajesticBankAPI { return ExchangeResponse(value: limit); } catch (e, s) { - Logging.instance - .logd("getLimits exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getLimits exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -159,8 +163,11 @@ class MajesticBankAPI { return ExchangeResponse(value: limits); } catch (e, s) { - Logging.instance - .logd("getLimits exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getLimits exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -228,9 +235,10 @@ class MajesticBankAPI { return ExchangeResponse(value: result); } catch (e, s) { - Logging.instance.logd( - "calculateOrder $fromCurrency-$receiveCurrency exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "calculateOrder $fromCurrency-$receiveCurrency exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -276,8 +284,11 @@ class MajesticBankAPI { return ExchangeResponse(value: order); } catch (e, s) { - Logging.instance - .logd("createOrder exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "createOrder exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -331,8 +342,8 @@ class MajesticBankAPI { return ExchangeResponse(value: order); } catch (e, s) { - Logging.instance.logd("createFixedRateOrder exception: $e\n$s", - level: LogLevel.Error); + Logging.instance + .e("createFixedRateOrder exception: ", error: e, stackTrace: s); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -379,9 +390,10 @@ class MajesticBankAPI { return ExchangeResponse(value: status); } catch (e, s) { - Logging.instance.logd( - "trackOrder exception when trying to parse $json: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "trackOrder exception when trying to parse $json: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( diff --git a/lib/services/exchange/nanswap/nanswap_api.dart b/lib/services/exchange/nanswap/nanswap_api.dart index a5435e15f..7d2465530 100644 --- a/lib/services/exchange/nanswap/nanswap_api.dart +++ b/lib/services/exchange/nanswap/nanswap_api.dart @@ -47,9 +47,10 @@ class NanswapAPI { return parsed; } catch (e, s) { - Logging.instance.logd( - "NanswapAPI._makeRequest($uri) HTTP:$code threw: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "NanswapAPI._makeRequest($uri) HTTP:$code threw: ", + error: e, + stackTrace: s, ); rethrow; } @@ -81,9 +82,10 @@ class NanswapAPI { return parsed; } catch (e, s) { - Logging.instance.logd( - "NanswapAPI._makePostRequest($uri) HTTP:$code threw: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "NanswapAPI._makePostRequest($uri) HTTP:$code threw: ", + error: e, + stackTrace: s, ); rethrow; } @@ -135,9 +137,10 @@ class NanswapAPI { return ExchangeResponse(value: result); } catch (e, s) { - Logging.instance.logd( - "Nanswap.getSupportedCurrencies() exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Nanswap.getSupportedCurrencies() exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -198,17 +201,19 @@ class NanswapAPI { map, ), ); - } catch (_) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.e( "Nanswap.getEstimate() response was: $json", - level: LogLevel.Error, + error: e, + stackTrace: s, ); rethrow; } } catch (e, s) { - Logging.instance.logd( - "Nanswap.getEstimate() exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Nanswap.getEstimate() exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -271,9 +276,10 @@ class NanswapAPI { ), ); } catch (e, s) { - Logging.instance.logd( - "Nanswap.getEstimateReverse() exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Nanswap.getEstimateReverse() exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -322,9 +328,10 @@ class NanswapAPI { ), ); } catch (e, s) { - Logging.instance.logd( - "Nanswap.getOrderLimits() exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Nanswap.getOrderLimits() exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -419,9 +426,10 @@ class NanswapAPI { rethrow; } } catch (e, s) { - Logging.instance.logd( - "Nanswap.createOrder() exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Nanswap.createOrder() exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -502,9 +510,10 @@ class NanswapAPI { rethrow; } } catch (e, s) { - Logging.instance.logd( - "Nanswap.getOrder($id) exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Nanswap.getOrder($id) exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( diff --git a/lib/services/exchange/simpleswap/simpleswap_api.dart b/lib/services/exchange/simpleswap/simpleswap_api.dart index 4573319e5..0a532822d 100644 --- a/lib/services/exchange/simpleswap/simpleswap_api.dart +++ b/lib/services/exchange/simpleswap/simpleswap_api.dart @@ -59,10 +59,8 @@ class SimpleSwapAPI { return parsed; } catch (e, s) { - Logging.instance.logd( - "_makeRequest($uri) HTTP:$code threw: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("_makeRequest($uri) HTTP:$code threw: ", error: e, stackTrace: s); rethrow; } } @@ -88,8 +86,11 @@ class SimpleSwapAPI { throw Exception("response: ${response.body}"); } catch (e, s) { - Logging.instance - .logd("_makeRequest($uri) threw: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "_makeRequest($uri) threw", + error: e, + stackTrace: s, + ); rethrow; } } @@ -149,10 +150,8 @@ class SimpleSwapAPI { ); return ExchangeResponse(value: trade, exception: null); } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("getAvailableCurrencies exception: ", error: e, stackTrace: s); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -177,10 +176,8 @@ class SimpleSwapAPI { return await compute(_parseAvailableCurrenciesJson, jsonArray as List); } catch (e, s) { - Logging.instance.logd( - "getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("getAvailableCurrencies exception: ", error: e, stackTrace: s); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -212,9 +209,10 @@ class SimpleSwapAPI { return ExchangeResponse(value: currencies); } catch (e, s) { - Logging.instance.logd( - "_parseAvailableCurrenciesJson exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "_parseAvailableCurrenciesJson exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -246,8 +244,11 @@ class SimpleSwapAPI { ), ); } catch (e, s) { - Logging.instance - .logd("getCurrency exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getCurrency exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -279,8 +280,11 @@ class SimpleSwapAPI { ); return result; } catch (e, s) { - Logging.instance - .logd("getAllPairs exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getAllPairs exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -321,9 +325,10 @@ class SimpleSwapAPI { return ExchangeResponse(value: pairs); } catch (e, s) { - Logging.instance.logd( - "_parseAvailableCurrenciesJson exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "_parseAvailableCurrenciesJson exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -358,8 +363,11 @@ class SimpleSwapAPI { return ExchangeResponse(value: jsonObject as String); } catch (e, s) { - Logging.instance - .logd("getEstimated exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getEstimated exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -415,8 +423,11 @@ class SimpleSwapAPI { return ExchangeResponse(value: trade); } catch (e, s) { - Logging.instance - .logd("getExchange exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getExchange exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -454,8 +465,11 @@ class SimpleSwapAPI { ), ); } catch (e, s) { - Logging.instance - .logd("getRange exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getRange exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -489,9 +503,10 @@ class SimpleSwapAPI { ); return result; } catch (e, s) { - Logging.instance.logd( - "getAvailableFixedRateMarkets exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableFixedRateMarkets exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -501,9 +516,10 @@ class SimpleSwapAPI { ); } } catch (e, s) { - Logging.instance.logd( - "getAvailableFixedRateMarkets exception: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getAvailableFixedRateMarkets exception: ", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( diff --git a/lib/services/exchange/trocador/trocador_api.dart b/lib/services/exchange/trocador/trocador_api.dart index 09eaeefe8..9aff6d872 100644 --- a/lib/services/exchange/trocador/trocador_api.dart +++ b/lib/services/exchange/trocador/trocador_api.dart @@ -70,10 +70,8 @@ abstract class TrocadorAPI { return json; } catch (e, s) { - Logging.instance.logd( - "_makeRequest($uri) HTTP:$code threw: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("_makeRequest($uri) HTTP:$code threw: ", error: e, stackTrace: s); rethrow; } } @@ -106,8 +104,11 @@ abstract class TrocadorAPI { throw Exception("unexpected json: $json"); } } catch (e, s) { - Logging.instance - .logd("getCoins exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getCoins exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -137,8 +138,11 @@ abstract class TrocadorAPI { return ExchangeResponse(value: TrocadorTrade.fromMap(map)); } catch (e, s) { - Logging.instance - .logd("getTrade exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getTrade exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -212,8 +216,11 @@ abstract class TrocadorAPI { return ExchangeResponse(value: TrocadorRate.fromMap(map)); } catch (e, s) { - Logging.instance - .logd("getNewRate exception: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "getNewRate exception", + error: e, + stackTrace: s, + ); return ExchangeResponse( exception: ExchangeException( e.toString(), @@ -328,9 +335,10 @@ abstract class TrocadorAPI { "This trade couldn't be completed. Please select another provider."; } - Logging.instance.logd( - "_getNewTrade failed to parse response: $json\n$e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "_getNewTrade failed to parse response: $json\n", + error: e, + stackTrace: s, ); return ExchangeResponse( exception: ExchangeException( @@ -340,10 +348,7 @@ abstract class TrocadorAPI { ); } } catch (e, s) { - Logging.instance.logd( - "_getNewTrade exception: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("_getNewTrade exception: ", error: e, stackTrace: s); return ExchangeResponse( exception: ExchangeException( e.toString(), diff --git a/lib/services/frost.dart b/lib/services/frost.dart index d0dc08d99..76c0b5db9 100644 --- a/lib/services/frost.dart +++ b/lib/services/frost.dart @@ -35,10 +35,7 @@ abstract class Frost { return participants; } catch (e, s) { - Logging.instance.logd( - "getParticipants failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("getParticipants failed: ", error: e, stackTrace: s); rethrow; } } @@ -48,10 +45,7 @@ abstract class Frost { decodeMultisigConfig(multisigConfig: encodedConfig); return true; } catch (e, s) { - Logging.instance.logd( - "validateEncodedMultisigConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("validateEncodedMultisigConfig failed: ", error: e, stackTrace: s); return false; } } @@ -66,10 +60,7 @@ abstract class Frost { return threshold; } catch (e, s) { - Logging.instance.logd( - "getThreshold failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("getThreshold failed: ", error: e, stackTrace: s); rethrow; } } @@ -144,10 +135,7 @@ abstract class Frost { inputs: outputs, ); } catch (e, s) { - Logging.instance.logd( - "extractDataFromSignConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("extractDataFromSignConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -168,10 +156,7 @@ abstract class Frost { return config; } catch (e, s) { - Logging.instance.logd( - "createMultisigConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("createMultisigConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -204,10 +189,7 @@ abstract class Frost { secretShareMachineWrapperPtr: machinePtr, ); } catch (e, s) { - Logging.instance.logd( - "startKeyGeneration failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("startKeyGeneration failed: ", error: e, stackTrace: s); rethrow; } } @@ -234,10 +216,7 @@ abstract class Frost { return (share: share, secretSharesResPtr: secretSharesResPtr); } catch (e, s) { - Logging.instance.logd( - "generateSecretShares failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("generateSecretShares failed: ", error: e, stackTrace: s); rethrow; } } @@ -275,10 +254,7 @@ abstract class Frost { serializedKeys: serializedKeys, ); } catch (e, s) { - Logging.instance.logd( - "completeKeyGeneration failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("completeKeyGeneration failed: ", error: e, stackTrace: s); rethrow; } } @@ -322,10 +298,7 @@ abstract class Frost { return signConfig; } catch (e, s) { - Logging.instance.logd( - "createSignConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("createSignConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -352,10 +325,7 @@ abstract class Frost { machinePtr: attemptSignRes.ref.machine, ); } catch (e, s) { - Logging.instance.logd( - "attemptSignConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("attemptSignConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -378,10 +348,7 @@ abstract class Frost { machinePtr: continueSignRes.ref.machine, ); } catch (e, s) { - Logging.instance.logd( - "continueSigning failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("continueSigning failed: ", error: e, stackTrace: s); rethrow; } } @@ -398,10 +365,7 @@ abstract class Frost { return rawTransaction; } catch (e, s) { - Logging.instance.logd( - "completeSigning failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("completeSigning failed: ", error: e, stackTrace: s); rethrow; } } @@ -419,10 +383,7 @@ abstract class Frost { ); return configPtr; } catch (e, s) { - Logging.instance.logd( - "decodedSignConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("decodedSignConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -443,10 +404,7 @@ abstract class Frost { return config; } catch (e, s) { - Logging.instance.logd( - "createResharerConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("createResharerConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -469,10 +427,7 @@ abstract class Frost { machine: result.machine, ); } catch (e, s) { - Logging.instance.logd( - "beginResharer failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("beginResharer failed: ", error: e, stackTrace: s); rethrow; } } @@ -498,10 +453,7 @@ abstract class Frost { prior: result.machine, ); } catch (e, s) { - Logging.instance.logd( - "beginReshared failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("beginReshared failed: ", error: e, stackTrace: s); rethrow; } } @@ -518,10 +470,7 @@ abstract class Frost { ); return result; } catch (e, s) { - Logging.instance.logd( - "finishResharer failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("finishResharer failed: ", error: e, stackTrace: s); rethrow; } } @@ -542,10 +491,7 @@ abstract class Frost { ); return result; } catch (e, s) { - Logging.instance.logd( - "finishReshared failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("finishReshared failed: ", error: e, stackTrace: s); rethrow; } } @@ -558,10 +504,7 @@ abstract class Frost { return config; } catch (e, s) { - Logging.instance.logd( - "decodedResharerConfig failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("decodedResharerConfig failed: ", error: e, stackTrace: s); rethrow; } } @@ -631,10 +574,7 @@ abstract class Frost { newParticipants: newParticipants, ); } catch (e, s) { - Logging.instance.logd( - "extractResharerConfigData failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("extractResharerConfigData failed: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/services/fusion_tor_service.dart b/lib/services/fusion_tor_service.dart index d7bf5181b..caa0ec2ee 100644 --- a/lib/services/fusion_tor_service.dart +++ b/lib/services/fusion_tor_service.dart @@ -62,10 +62,7 @@ class FusionTorService { try { await _tor!.start(torDataDirPath: _torDataDirPath!); } catch (e, s) { - Logging.instance.logd( - "FusionTorService.start failed: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("FusionTorService.start failed: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/services/monkey_service.dart b/lib/services/monkey_service.dart index 1f326cf5a..0ae745d34 100644 --- a/lib/services/monkey_service.dart +++ b/lib/services/monkey_service.dart @@ -39,10 +39,7 @@ class MonKeyService { ); } } catch (e, s) { - Logging.instance.logd( - "Failed fetchMonKey($address): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Failed fetchMonKey($address): ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/services/node_service.dart b/lib/services/node_service.dart index c32664839..35f595050 100644 --- a/lib/services/node_service.dart +++ b/lib/services/node_service.dart @@ -293,7 +293,7 @@ class NodeService extends ChangeNotifier { final json = jsonDecode(response.body) as Map; final result = jsonDecode(json['result'] as String); final map = jsonDecode(result as String); - Logging.instance.logd(map, level: LogLevel.Info); + Logging.instance.d(map); for (final coin in AppConfig.coins) { final nodeList = List>.from( @@ -330,8 +330,11 @@ class NodeService extends ChangeNotifier { } } } catch (e, s) { - Logging.instance - .logd("updateCommunityNodes() failed: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "updateCommunityNodes() failed", + error: e, + stackTrace: s, + ); } } } diff --git a/lib/services/notifications_service.dart b/lib/services/notifications_service.dart index 181678f9e..93e09aceb 100644 --- a/lib/services/notifications_service.dart +++ b/lib/services/notifications_service.dart @@ -105,8 +105,7 @@ class NotificationsService extends ChangeNotifier { stopCheckingWatchedTransactions(); _timer = Timer.periodic(notificationRefreshInterval, (_) { - Logging.instance - .logd("Periodic notifications update check", level: LogLevel.Info); + Logging.instance.d("Periodic notifications update check"); if (prefs.externalCalls) { _checkTrades(); } @@ -222,7 +221,7 @@ class NotificationsService extends ChangeNotifier { } on NoSuchTransactionException catch (e, s) { await _deleteWatchedTxNotification(notification); } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("$e $s", error: e, stackTrace: s); } } } diff --git a/lib/services/price.dart b/lib/services/price.dart index f8a5139f5..a3c31ef17 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -131,9 +131,8 @@ class PriceAPI { final externalCalls = Prefs.instance.externalCalls; if ((!Util.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { - Logging.instance.logd( + Logging.instance.i( "User does not want to use external calls", - level: LogLevel.Info, ); return _cachedPrices; } @@ -172,10 +171,8 @@ class PriceAPI { return _cachedPrices; } catch (e, s) { - Logging.instance.logd( - "getPricesAnd24hChange($baseCurrency): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("getPricesAnd24hChange($baseCurrency): ", error: e, stackTrace: s); // return previous cached values return _cachedPrices; } @@ -187,9 +184,8 @@ class PriceAPI { if ((!Util.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { - Logging.instance.logd( + Logging.instance.i( "User does not want to use external calls", - level: LogLevel.Info, ); return null; } @@ -208,9 +204,10 @@ class PriceAPI { final json = jsonDecode(response.body) as List; return List.from(json); } catch (e, s) { - Logging.instance.logd( - "availableBaseCurrencies() using $uriString: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "availableBaseCurrencies() using $uriString: ", + error: e, + stackTrace: s, ); return null; } @@ -229,9 +226,8 @@ class PriceAPI { final externalCalls = Prefs.instance.externalCalls; if ((!Util.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { - Logging.instance.logd( + Logging.instance.i( "User does not want to use external calls", - level: LogLevel.Info, ); return tokenPrices; } @@ -273,9 +269,10 @@ class PriceAPI { return tokenPrices; } catch (e, s) { - Logging.instance.logd( - "getPricesAnd24hChangeForEthTokens($baseCurrency,$contractAddresses): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "getPricesAnd24hChangeForEthTokens($baseCurrency,$contractAddresses): ", + error: e, + stackTrace: s, ); // return previous cached values return tokenPrices; diff --git a/lib/services/tor_service.dart b/lib/services/tor_service.dart index 49ab83a0b..542032df7 100644 --- a/lib/services/tor_service.dart +++ b/lib/services/tor_service.dart @@ -85,10 +85,7 @@ class TorService { // Complete the future. return; } catch (e, s) { - Logging.instance.logd( - "TorService.start failed: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("TorService.start failed: ", error: e, stackTrace: s); // _enabled should already be false // Fire a TorConnectionStatusChangedEvent on the event bus. diff --git a/lib/services/wallets.dart b/lib/services/wallets.dart index 701f77d9b..07856e6ee 100644 --- a/lib/services/wallets.dart +++ b/lib/services/wallets.dart @@ -72,10 +72,7 @@ class Wallets { SecureStorageInterface secureStorage, ) async { final walletId = info.walletId; - Logging.instance.logd( - "deleteWallet called with walletId=$walletId", - level: LogLevel.Warning, - ); + Logging.instance.d("deleteWallet called with walletId=$walletId"); final wallet = _wallets[walletId]; _wallets.remove(walletId); @@ -96,24 +93,21 @@ class Wallets { type: lib_monero_compat.WalletType.wownero, appRoot: await StackFileSystem.applicationRootDirectory(), ); - Logging.instance - .logd("monero wallet: $walletId deleted", level: LogLevel.Info); + Logging.instance.d("monero wallet: $walletId deleted"); } else if (info.coin is Monero) { await lib_monero_compat.deleteWalletFiles( name: walletId, type: lib_monero_compat.WalletType.monero, appRoot: await StackFileSystem.applicationRootDirectory(), ); - Logging.instance - .logd("monero wallet: $walletId deleted", level: LogLevel.Info); + Logging.instance.d("monero wallet: $walletId deleted"); } else if (info.coin is Epiccash) { final deleteResult = await deleteEpicWallet( walletId: walletId, secureStore: secureStorage, ); - Logging.instance.logd( + Logging.instance.d( "epic wallet: $walletId deleted with result: $deleteResult", - level: LogLevel.Info, ); } @@ -210,11 +204,9 @@ class Wallets { for (final walletInfo in walletInfoList) { try { final isVerified = await walletInfo.isMnemonicVerified(mainDB.isar); - Logging.instance.logd( - "LOADING WALLET: ${walletInfo.name}:${walletInfo.walletId} " - "IS VERIFIED: $isVerified", - level: LogLevel.Info, - ); + Logging.instance + .d("LOADING WALLET: ${walletInfo.name}:${walletInfo.walletId} " + "IS VERIFIED: $isVerified"); if (isVerified) { // TODO: integrate this into the new wallets somehow? @@ -252,7 +244,7 @@ class Wallets { // await walletsService.deleteWallet(walletInfo.name, false); } } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Fatal); + Logging.instance.w("", error: e, stackTrace: s); continue; } } @@ -317,11 +309,9 @@ class Wallets { for (final walletInfo in walletInfoList) { try { final isVerified = await walletInfo.isMnemonicVerified(mainDB.isar); - Logging.instance.logd( - "LOADING WALLET: ${walletInfo.name}:${walletInfo.walletId} " - "IS VERIFIED: $isVerified", - level: LogLevel.Info, - ); + Logging.instance + .d("LOADING WALLET: ${walletInfo.name}:${walletInfo.walletId} " + "IS VERIFIED: $isVerified"); if (isVerified) { // TODO: integrate this into the new wallets somehow? @@ -355,7 +345,11 @@ class Wallets { deleteFutures.add(_deleteWallet(walletInfo.walletId)); } } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Fatal); + Logging.instance.w( + "$e $s", + error: e, + stackTrace: s, + ); continue; } } @@ -447,11 +441,9 @@ class Wallets { for (final walletInfo in walletInfoList) { try { final isVerified = await walletInfo.isMnemonicVerified(mainDB.isar); - Logging.instance.logd( - "LOADING WALLET: ${walletInfo.name}:${walletInfo.walletId} " - "IS VERIFIED: $isVerified", - level: LogLevel.Info, - ); + Logging.instance + .d("LOADING WALLET: ${walletInfo.name}:${walletInfo.walletId} " + "IS VERIFIED: $isVerified"); if (isVerified) { // TODO: integrate this into the new wallets somehow? @@ -485,7 +477,11 @@ class Wallets { deleteFutures.add(_deleteWallet(walletInfo.walletId)); } } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Fatal); + Logging.instance.w( + "$e $s", + error: e, + stackTrace: s, + ); continue; } } @@ -509,9 +505,8 @@ class Wallets { Future _refreshFutures(List idsToRefresh) async { final start = DateTime.now(); - Logging.instance.logd( + Logging.instance.d( "Initial refresh start: ${start.toUtc()}", - level: LogLevel.Warning, ); const groupCount = 3; for (int i = 0; i < idsToRefresh.length; i += groupCount) { @@ -526,10 +521,8 @@ class Wallets { } await Future.wait(futures); } - Logging.instance.logd( - "Initial refresh duration: ${DateTime.now().difference(start)}", - level: LogLevel.Warning, - ); + Logging.instance + .d("Initial refresh duration: ${DateTime.now().difference(start)}"); } if (walletInitFutures.isNotEmpty && walletsToInitLinearly.isNotEmpty) { @@ -580,9 +573,8 @@ class Wallets { for (final wallet in wallets) { final isVerified = await wallet.info.isMnemonicVerified(mainDB.isar); - Logging.instance.logd( + Logging.instance.d( "LOADING WALLET: ${wallet.info.name}:${wallet.walletId} IS VERIFIED: $isVerified", - level: LogLevel.Info, ); if (isVerified) { diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index 7d0e90c33..25d768fe8 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -75,9 +75,8 @@ class WalletsService extends ChangeNotifier { final names = DB.instance .get(boxName: DB.boxNameAllWalletsData, key: 'names') as Map?; if (names == null) { - Logging.instance.logd( + Logging.instance.e( "Fetched wallet 'names' returned null. Setting initializing 'names'", - level: LogLevel.Info, ); await DB.instance.put( boxName: DB.boxNameAllWalletsData, @@ -86,7 +85,7 @@ class WalletsService extends ChangeNotifier { ); return {}; } - Logging.instance.logd("Fetched wallet names: $names", level: LogLevel.Info); + Logging.instance.d("Fetched wallet names: $names"); final mapped = Map.from(names); mapped.removeWhere((name, dyn) { final jsonObject = Map.from(dyn as Map); @@ -94,9 +93,10 @@ class WalletsService extends ChangeNotifier { AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String); return false; } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Error, ${jsonObject["coin"]} does not exist", - level: LogLevel.Error, + error: e, + stackTrace: s, ); return true; } diff --git a/lib/themes/theme_service.dart b/lib/themes/theme_service.dart index 930280535..1915239a5 100644 --- a/lib/themes/theme_service.dart +++ b/lib/themes/theme_service.dart @@ -77,9 +77,9 @@ class ThemeService { if (file.isFile) { // TODO more sanitation? if (file.name.contains("..")) { - Logging.instance.logd( + Logging.instance.e( "Bad theme asset file path: ${file.name}", - level: LogLevel.Error, + stackTrace: StackTrace.current, ); } else { final os = OutputFileStream("$assetsPath/${file.name}"); @@ -110,9 +110,9 @@ class ThemeService { await dir.delete(recursive: true); } } else { - Logging.instance.logd( + Logging.instance.w( "Failed to delete theme $themeId", - level: LogLevel.Warning, + stackTrace: StackTrace.current, ); } } @@ -142,18 +142,12 @@ class ThemeService { } Future _updateDefaultTheme(String name) async { - Logging.instance.logd( - "Updating default $name theme...", - level: LogLevel.Info, - ); + Logging.instance.w("Updating default $name theme..."); final zip = await rootBundle.load("assets/default_themes/$name.zip"); await ThemeService.instance.install( themeArchiveData: zip.buffer.asUint8List(), ); - Logging.instance.logd( - "Updating default $name theme... finished", - level: LogLevel.Info, - ); + Logging.instance.w("Updating default $name theme... finished"); } // TODO more thorough check/verification of theme @@ -174,9 +168,9 @@ class ThemeService { await Directory("${themesDir.path}/$themeId/assets").exists(); if (!jsonFileExists || !assetsDirExists) { - Logging.instance.logd( + Logging.instance.w( "Theme $themeId found in DB but is missing files", - level: LogLevel.Warning, + stackTrace: StackTrace.current, ); } @@ -204,10 +198,8 @@ class ThemeService { return result; } catch (e, s) { - Logging.instance.logd( - "Failed to fetch themes list: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance + .w("Failed to fetch themes list: ", error: e, stackTrace: s); rethrow; } } @@ -236,10 +228,8 @@ class ThemeService { ); } } catch (e, s) { - Logging.instance.logd( - "Failed to fetch themes list: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance + .w("Failed to fetch themes list: ", error: e, stackTrace: s); rethrow; } } @@ -279,10 +269,10 @@ class StackThemeMetaData { previewImageUrl: map["previewImageUrl"] as String, ); } catch (e, s) { - Logging.instance.logd( - "Failed to create instance of StackThemeMetaData using $map: \n$e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f( + "Failed to create instance of StackThemeMetaData using $map", + error: e, + stackTrace: s); rethrow; } } diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index d63dca66f..171dc09b2 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -155,7 +155,7 @@ class AddressUtils { additionalParams: filteredParams, ); } catch (e, s) { - logging?.logd("$e\n$s", level: LogLevel.Error); + logging?.e("", error: e, stackTrace: s); return null; } } diff --git a/lib/utilities/biometrics.dart b/lib/utilities/biometrics.dart index 6dbb05982..9a30d5fe3 100644 --- a/lib/utilities/biometrics.dart +++ b/lib/utilities/biometrics.dart @@ -27,16 +27,14 @@ class Biometrics { required String title, }) async { if (!(Platform.isIOS || Platform.isAndroid)) { - Logging.instance.logd( + Logging.instance.w( "Tried to use Biometrics.authenticate() on a platform that is not Android or iOS! ...returning false.", - level: LogLevel.Error, ); return false; } if (integrationTestFlag) { - Logging.instance.logd( + Logging.instance.w( "Tried to use Biometrics.authenticate() during integration testing. Returning false.", - level: LogLevel.Warning, ); return false; } @@ -50,12 +48,12 @@ class Biometrics { // debugPrint("isDeviceSupported: $isDeviceSupported"); if (canCheckBiometrics && isDeviceSupported) { - List availableSystems = + final List availableSystems = await localAuth.getAvailableBiometrics(); - Logging.instance.logd( + Logging.instance.w( "Bio availableSystems: $availableSystems", - level: LogLevel.Info, + stackTrace: StackTrace.current, ); //TODO properly handle caught exceptions @@ -78,10 +76,11 @@ class Biometrics { if (didAuthenticate) { return true; } - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.e( "local_auth exception caught in Biometrics.authenticate(), e: $e", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } } diff --git a/lib/utilities/connection_check/electrum_connection_check.dart b/lib/utilities/connection_check/electrum_connection_check.dart index e90d7896c..325cfa059 100644 --- a/lib/utilities/connection_check/electrum_connection_check.dart +++ b/lib/utilities/connection_check/electrum_connection_check.dart @@ -27,9 +27,8 @@ Future checkElectrumServer({ // And the killswitch isn't set... if (!_prefs.torKillSwitch) { // Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function. - Logging.instance.logd( + Logging.instance.w( "Tor preference set but Tor is not enabled, killswitch not set, connecting to Electrum adapter through clearnet", - level: LogLevel.Warning, ); } else { // ... But if the killswitch is set, then we throw an exception. @@ -62,7 +61,11 @@ Future checkElectrumServer({ return true; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Debug); + Logging.instance.e( + "$e\n$s", + error: e, + stackTrace: s, + ); return false; } } diff --git a/lib/utilities/desktop_password_service.dart b/lib/utilities/desktop_password_service.dart index 7197cced8..39243962b 100644 --- a/lib/utilities/desktop_password_service.dart +++ b/lib/utilities/desktop_password_service.dart @@ -68,10 +68,7 @@ class DPS { await _put(key: _kKeyBlobKey, value: await _handler!.getKeyBlob()); await _updateStoredKeyBlobVersion(kLatestBlobVersion); } catch (e, s) { - Logging.instance.logd( - "${_getMessageFromException(e)}\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("${_getMessageFromException(e)}\n$s", error: e, stackTrace: s); rethrow; } } @@ -104,10 +101,7 @@ class DPS { await _updateStoredKeyBlobVersion(kLatestBlobVersion); } } catch (e, s) { - Logging.instance.logd( - "${_getMessageFromException(e)}\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("${_getMessageFromException(e)}\n$s", error: e, stackTrace: s); throw Exception(_getMessageFromException(e)); } } @@ -125,10 +119,7 @@ class DPS { // existing passphrase matches key blob return true; } catch (e, s) { - Logging.instance.logd( - "${_getMessageFromException(e)}\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("${_getMessageFromException(e)}\n$s", error: e, stackTrace: s,); // password is wrong or some other error return false; } @@ -161,10 +152,7 @@ class DPS { // successfully updated passphrase return true; } catch (e, s) { - Logging.instance.logd( - "${_getMessageFromException(e)}\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("${_getMessageFromException(e)}\n$s", error: e, stackTrace: s,); return false; } } @@ -189,10 +177,7 @@ class DPS { box = await DB.instance.hive.openBox(kBoxNameDesktopData); await box.put(key, value); } catch (e, s) { - Logging.instance.logd( - "DPS failed put($key): $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("DPS failed put($key): ", error: e, stackTrace: s); } finally { await box?.close(); } @@ -205,10 +190,7 @@ class DPS { box = await DB.instance.hive.openBox(kBoxNameDesktopData); value = box.get(key); } catch (e, s) { - Logging.instance.logd( - "DPS failed get($key): $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance.f("DPS failed get($key): ", error: e, stackTrace: s); } finally { await box?.close(); } diff --git a/lib/utilities/extensions/impl/contract_abi.dart b/lib/utilities/extensions/impl/contract_abi.dart index 401e8af04..74f252a69 100644 --- a/lib/utilities/extensions/impl/contract_abi.dart +++ b/lib/utilities/extensions/impl/contract_abi.dart @@ -68,10 +68,7 @@ extension ContractAbiExtensions on ContractAbi { return ContractAbi(name, functions, events); } catch (e, s) { - Logging.instance.logd( - "Failed to parse ABI for $name: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Failed to parse ABI for $name: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/utilities/git_status.dart b/lib/utilities/git_status.dart index 0f873df3f..0a3f081a6 100644 --- a/lib/utilities/git_status.dart +++ b/lib/utilities/git_status.dart @@ -138,7 +138,7 @@ abstract class GitStatus { String project, String commit, ) async { - Logging.instance.logd("doesCommitExist", level: LogLevel.Info); + Logging.instance.d("doesCommitExist"); final Client client = Client(); try { final uri = Uri.parse( @@ -151,21 +151,17 @@ abstract class GitStatus { ); final response = jsonDecode(commitQuery.body.toString()); - Logging.instance.logd( - "doesCommitExist $project $commit $response", - level: LogLevel.Info, - ); + Logging.instance.d("doesCommitExist $project $commit $response"); bool isThereCommit; try { isThereCommit = response['sha'] == commit; - Logging.instance - .logd("isThereCommit $isThereCommit", level: LogLevel.Info); + Logging.instance.d("isThereCommit $isThereCommit"); return isThereCommit; } catch (e, s) { return false; } } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("$e $s", error: e, stackTrace: s); return false; } } @@ -176,7 +172,7 @@ abstract class GitStatus { String branch, String commit, ) async { - Logging.instance.logd("doesCommitExist", level: LogLevel.Info); + Logging.instance.d("doesCommitExist"); final Client client = Client(); try { final uri = Uri.parse( @@ -189,20 +185,17 @@ abstract class GitStatus { ); final response = jsonDecode(commitQuery.body.toString()); - Logging.instance.logd( - "isHeadCommit $project $commit $branch $response", - level: LogLevel.Info, - ); + Logging.instance.d("isHeadCommit $project $commit $branch $response"); bool isHead; try { isHead = response['sha'] == commit; - Logging.instance.logd("isHead $isHead", level: LogLevel.Info); + Logging.instance.d("isHead $isHead"); return isHead; - } catch (e, s) { - return false; + } catch (e) { + rethrow; } } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("", error: e, stackTrace: s); return false; } } diff --git a/lib/utilities/logger.dart b/lib/utilities/logger.dart index 7243de77a..f62b1ea4e 100644 --- a/lib/utilities/logger.dart +++ b/lib/utilities/logger.dart @@ -17,7 +17,6 @@ import 'dart:ui'; import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart' as spark; import 'package:logger/logger.dart'; -import 'enums/log_level_enum.dart'; import 'util.dart'; export 'enums/log_level_enum.dart'; @@ -144,18 +143,6 @@ class Logging { ? message.toString() : JsonEncoder.withIndent(' ', (o) => o.toString()).convert(message); - @core.Deprecated("Use Logging.instance.log instead") - void logd( - core.Object? object, { - required LogLevel level, - core.bool printToConsole = true, - core.bool printFullLength = false, - }) => - log( - level.getLoggerLevel(), - object, - ); - void log( Level level, dynamic message, { diff --git a/lib/utilities/show_loading.dart b/lib/utilities/show_loading.dart index 7f97ca851..040bc2303 100644 --- a/lib/utilities/show_loading.dart +++ b/lib/utilities/show_loading.dart @@ -71,10 +71,7 @@ Future showLoading({ result = await whileFuture; } } catch (e, s) { - Logging.instance.logd( - "showLoading caught: $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("showLoading caught: ", error: e, stackTrace: s); ex = e is Exception ? e : Exception(e.toString()); } diff --git a/lib/utilities/test_epic_box_connection.dart b/lib/utilities/test_epic_box_connection.dart index 8e98e4ccf..1c39390e2 100644 --- a/lib/utilities/test_epic_box_connection.dart +++ b/lib/utilities/test_epic_box_connection.dart @@ -41,7 +41,7 @@ Future _testEpicBoxNodeConnection(Uri uri) async { return false; } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); return false; } } @@ -87,7 +87,7 @@ Future testEpicNodeConnection(NodeFormData data) async { return null; } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); return null; } } diff --git a/lib/utilities/test_monero_node_connection.dart b/lib/utilities/test_monero_node_connection.dart index 0abfff5ae..7eba0ee30 100644 --- a/lib/utilities/test_monero_node_connection.dart +++ b/lib/utilities/test_monero_node_connection.dart @@ -103,7 +103,7 @@ Future testMoneroNodeConnection( return MoneroNodeConnectionResponse(null, null, null, success); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); return MoneroNodeConnectionResponse(null, null, null, false); } finally { await socket?.close(); @@ -150,7 +150,7 @@ Future testMoneroNodeConnection( if (badCertResponse != null) { return badCertResponse!; } else { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w("$e\n$s", error: e, stackTrace: s,); return MoneroNodeConnectionResponse(null, null, null, false); } } finally { diff --git a/lib/utilities/test_node_connection.dart b/lib/utilities/test_node_connection.dart index f3e1a9618..b212d3a0a 100644 --- a/lib/utilities/test_node_connection.dart +++ b/lib/utilities/test_node_connection.dart @@ -100,17 +100,15 @@ Future testNodeConnection({ if (ref.read(prefsChangeNotifierProvider).useTor) { if (formData.netOption! == TorPlainNetworkOption.clear) { - Logging.instance.logd( + Logging.instance.w( "This node is configured for non-TOR only but TOR is enabled", - level: LogLevel.Warning, ); return false; } } else { if (formData.netOption! == TorPlainNetworkOption.tor) { - Logging.instance.logd( + Logging.instance.w( "This node is configured for TOR only but TOR is disabled", - level: LogLevel.Warning, ); return false; } @@ -128,7 +126,11 @@ Future testNodeConnection({ onSuccess?.call(data); } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w( + "$e\n$s", + error: e, + stackTrace: s, + ); } break; @@ -175,7 +177,11 @@ Future testNodeConnection({ } } } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w( + "$e\n$s", + error: e, + stackTrace: s, + ); } break; @@ -251,9 +257,8 @@ Future testNodeConnection({ ); final health = await rpcClient.getHealth(); - Logging.instance.logd( + Logging.instance.i( "Solana testNodeConnection \"health=$health\"", - level: LogLevel.Info, ); return true; } catch (_) { @@ -283,9 +288,8 @@ Future testNodeConnection({ BlockfrostRequestBackendHealthStatus(), ); - Logging.instance.logd( + Logging.instance.i( "Cardano testNodeConnection \"health=$health\"", - level: LogLevel.Info, ); return health; diff --git a/lib/wallets/api/lelantus_ffi_wrapper.dart b/lib/wallets/api/lelantus_ffi_wrapper.dart index 5bb9dab11..3ee60d994 100644 --- a/lib/wallets/api/lelantus_ffi_wrapper.dart +++ b/lib/wallets/api/lelantus_ffi_wrapper.dart @@ -48,10 +48,7 @@ abstract final class LelantusFfiWrapper { try { return await compute(_restore, args); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from _restore(): $e\n$s", - level: LogLevel.Info, - ); + Logging.instance.i("Exception rethrown from _restore(): ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/wallets/api/tezos/tezos_api.dart b/lib/wallets/api/tezos/tezos_api.dart index 8e81f6451..49065433e 100644 --- a/lib/wallets/api/tezos/tezos_api.dart +++ b/lib/wallets/api/tezos/tezos_api.dart @@ -25,10 +25,7 @@ abstract final class TezosAPI { final result = jsonDecode(response.body); return result as int; } catch (e, s) { - Logging.instance.logd( - "Error occurred in TezosAPI while getting counter for $address: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in TezosAPI while getting counter for $address: ", error: e, stackTrace: s); rethrow; } } @@ -53,10 +50,7 @@ abstract final class TezosAPI { return account; } catch (e, s) { - Logging.instance.logd( - "Error occurred in TezosAPI while getting account for $address: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in TezosAPI while getting account for $address: ", error: e, stackTrace: s); rethrow; } } @@ -109,10 +103,7 @@ abstract final class TezosAPI { } return txs; } catch (e, s) { - Logging.instance.logd( - "Error occurred in TezosAPI while getting transactions for $address: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in TezosAPI while getting transactions for $address: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/wallets/api/tezos/tezos_rpc_api.dart b/lib/wallets/api/tezos/tezos_rpc_api.dart index a5da3b01e..4f9c71fe8 100644 --- a/lib/wallets/api/tezos/tezos_rpc_api.dart +++ b/lib/wallets/api/tezos/tezos_rpc_api.dart @@ -27,10 +27,11 @@ abstract final class TezosRpcAPI { final balance = BigInt.parse(response.body.substring(1, response.body.length - 2)); return balance; - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.e( "Error occurred in tezos_rpc_api.dart while getting balance for $address: $e", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } return null; @@ -53,10 +54,11 @@ abstract final class TezosRpcAPI { final jsonParsedResponse = jsonDecode(response.body); return int.parse(jsonParsedResponse["level"].toString()); - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.e( "Error occurred in tezos_rpc_api.dart while getting chain height for tezos: $e", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } return null; diff --git a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart index 5400ba457..3beaa0e8d 100644 --- a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart @@ -56,10 +56,7 @@ class BitcoinFrostWallet extends Wallet required List participants, required int threshold, }) async { - Logging.instance.logd( - "Generating new FROST wallet.", - level: LogLevel.Info, - ); + Logging.instance.i("Generating new FROST wallet."); try { final salt = frost @@ -108,9 +105,10 @@ class BitcoinFrostWallet extends Wallet await mainDB.putAddresses([address]); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from initializeNewFrost(): $e\n$s", - level: LogLevel.Fatal, + Logging.instance.f( + "Exception rethrown from initializeNewFrost(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -626,10 +624,7 @@ class BitcoinFrostWallet extends Wallet // TODO: [prio=none] Check for special Bitcoin outputs like ordinals. } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it): $txData"); continue; } @@ -683,13 +678,13 @@ class BitcoinFrostWallet extends Wallet if (index >= someSaneMaximum) { throw Exception( - "index < kFrostSecureStartingIndex hit someSaneMaximum"); + "index < kFrostSecureStartingIndex hit someSaneMaximum", + ); } } else { - Logging.instance.logd( + Logging.instance.f( "$runtimeType.checkSaveInitialReceivingAddress() failed due" " to missing serialized keys", - level: LogLevel.Fatal, ); } } @@ -698,13 +693,14 @@ class BitcoinFrostWallet extends Wallet @override Future confirmSend({required TxData txData}) async { try { - Logging.instance - .logd("confirmSend txData: $txData", level: LogLevel.Info); + Logging.instance.d("confirmSend txData: $txData"); final hex = txData.raw!; final txHash = await electrumXClient.broadcastTransaction(rawTx: hex); - Logging.instance.logd("Sent txHash: $txHash", level: LogLevel.Info); + Logging.instance.d( + "Sent txHash: $txHash", + ); // mark utxos as used final usedUTXOs = txData.utxos!.map((e) => e.copyWith(used: true)); @@ -718,9 +714,10 @@ class BitcoinFrostWallet extends Wallet return txData; } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown from confirmSend(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -804,11 +801,14 @@ class BitcoinFrostWallet extends Wallet ).raw.toInt(), ); - Logging.instance.logd("fetched fees: $feeObject", level: LogLevel.Info); + Logging.instance.i("fetched fees: $feeObject"); return feeObject; - } catch (e) { - Logging.instance.logd("Exception rethrown from _getFees(): $e", - level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e( + "Exception rethrown from _getFees(): $e", + error: e, + stackTrace: s, + ); rethrow; } } @@ -831,7 +831,7 @@ class BitcoinFrostWallet extends Wallet } if (serializedKeys == null || multisigConfig == null) { final err = "${info.coinName} wallet ${info.walletId} had null keys/cfg"; - Logging.instance.logd(err, level: LogLevel.Fatal); + Logging.instance.f(err, stackTrace: StackTrace.current); throw Exception(err); // TODO [prio=low]: handle null keys or config. This should not happen. } @@ -958,10 +958,8 @@ class BitcoinFrostWallet extends Wallet unawaited(refresh()); } catch (e, s) { - Logging.instance.logd( - "recoverFromSerializedKeys failed: $e\n$s", - level: LogLevel.Fatal, - ); + Logging.instance + .f("recoverFromSerializedKeys failed: ", error: e, stackTrace: s); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.unableToSync, @@ -1165,10 +1163,8 @@ class BitcoinFrostWallet extends Wallet return await mainDB.updateUTXOs(walletId, outputArray); } catch (e, s) { - Logging.instance.logd( - "Output fetch unsuccessful: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Output fetch unsuccessful: ", error: e, stackTrace: s); return false; } } @@ -1378,13 +1374,14 @@ class BitcoinFrostWallet extends Wallet final newNode = await _getCurrentElectrumXNode(); try { await electrumXClient.closeAdapter(); - } catch (e) { + } catch (e, s) { if (e.toString().contains("initialized")) { // Ignore. This should happen every first time the wallet is opened. } else { - Logging.instance.logd( - "Error closing electrumXClient: $e", - level: LogLevel.Error, + Logging.instance.e( + "Error closing electrumXClient", + error: e, + stackTrace: s, ); } } @@ -1479,11 +1476,9 @@ class BitcoinFrostWallet extends Wallet await checkChangeAddressForTransactions(); } } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from _checkChangeAddressForTransactions" - "($cryptoCurrency): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .i("Exception rethrown from _checkChangeAddressForTransactions" + "($cryptoCurrency): $e\n$s"); rethrow; } } @@ -1494,9 +1489,9 @@ class BitcoinFrostWallet extends Wallet try { throw Exception(); } catch (_, s) { - Logging.instance.logd( + Logging.instance.e( "checkReceivingAddressForTransactions called but reuse address flag set: $s", - level: LogLevel.Error, + stackTrace: s, ); } } @@ -1526,10 +1521,11 @@ class BitcoinFrostWallet extends Wallet } } } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Exception rethrown from _checkReceivingAddressForTransactions" - "($cryptoCurrency): $e\n$s", - level: LogLevel.Error, + "($cryptoCurrency)", + error: e, + stackTrace: s, ); rethrow; } @@ -1749,9 +1745,8 @@ class BitcoinFrostWallet extends Wallet int gapCounter = 0; int index = secure ? kFrostSecureStartingIndex : 0; for (; gapCounter < 20; index++) { - Logging.instance.logd( + Logging.instance.d( "Frost index: $index, \t GapCounter chain=$chain: $gapCounter", - level: LogLevel.Info, ); Address? address; @@ -1844,10 +1839,8 @@ class BitcoinFrostWallet extends Wallet return allTxHashes; } catch (e, s) { - Logging.instance.logd( - "$runtimeType._fetchHistory: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("$runtimeType._fetchHistory: ", error: e, stackTrace: s); rethrow; } } diff --git a/lib/wallets/wallet/impl/bitcoincash_wallet.dart b/lib/wallets/wallet/impl/bitcoincash_wallet.dart index a8bcc599d..666d5fd6b 100644 --- a/lib/wallets/wallet/impl/bitcoincash_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoincash_wallet.dart @@ -198,9 +198,10 @@ class BitcoincashWallet valueStringSats = prevOut.valueStringSats; addresses.addAll(prevOut.addresses); } catch (e, s) { - Logging.instance.logd( + Logging.instance.w( "Error getting prevOutJson: $e\nStack trace: $s", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } } @@ -293,9 +294,11 @@ class BitcoincashWallet // only found outputs owned by this wallet type = TransactionType.incoming; } else { - Logging.instance.logd( + Logging.instance.e( + "Unexpected tx found (ignoring it)", + ); + Logging.instance.d( "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, ); continue; } @@ -345,10 +348,17 @@ class BitcoincashWallet } } catch (e, s) { // Probably doesn't contain a cash token so just log failure - Logging.instance.logd( + Logging.instance.w( + "Script pub key cash token" + " parsing check failed", + error: e, + stackTrace: s, + ); + Logging.instance.d( "Script pub key \"$scriptPubKeyHex\" cash token" " parsing check failed: $e\n$s", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } diff --git a/lib/wallets/wallet/impl/cardano_wallet.dart b/lib/wallets/wallet/impl/cardano_wallet.dart index 3a555c2d3..3beafe5f5 100644 --- a/lib/wallets/wallet/impl/cardano_wallet.dart +++ b/lib/wallets/wallet/impl/cardano_wallet.dart @@ -76,10 +76,7 @@ class CardanoWallet extends Bip39Wallet { await mainDB.updateOrPutAddresses([address]); } } catch (e, s) { - Logging.instance.logd( - "$runtimeType checkSaveInitialReceivingAddress() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType checkSaveInitialReceivingAddress() failed: ", error: e, stackTrace: s); } } @@ -94,10 +91,7 @@ class CardanoWallet extends Bip39Wallet { return Future.value(health); } catch (e, s) { - Logging.instance.logd( - "Error ping checking in cardano_wallet.dart: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error ping checking in cardano_wallet.dart: ", error: e, stackTrace: s); return Future.value(false); } } @@ -146,10 +140,7 @@ class CardanoWallet extends Bip39Wallet { slow: fee, ); } catch (e, s) { - Logging.instance.logd( - "Error getting fees in cardano_wallet.dart: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error getting fees in cardano_wallet.dart: ", error: e, stackTrace: s); rethrow; } } @@ -264,10 +255,7 @@ class CardanoWallet extends Bip39Wallet { ); } } catch (e, s) { - Logging.instance.logd( - "$runtimeType Cardano prepareSend failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType Cardano prepareSend failed: ", error: e, stackTrace: s); rethrow; } } @@ -355,10 +343,7 @@ class CardanoWallet extends Bip39Wallet { txid: sentTx, ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType Cardano confirmSend failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType Cardano confirmSend failed: ", error: e, stackTrace: s); rethrow; } } @@ -425,10 +410,7 @@ class CardanoWallet extends Bip39Wallet { await info.updateBalance(newBalance: balance, isar: mainDB.isar); } catch (e, s) { - Logging.instance.logd( - "Error getting balance in cardano_wallet.dart: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error getting balance in cardano_wallet.dart: ", error: e, stackTrace: s); } } @@ -446,10 +428,7 @@ class CardanoWallet extends Bip39Wallet { isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "Error updating transactions in cardano_wallet.dart: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error updating transactions in cardano_wallet.dart: ", error: e, stackTrace: s); } } @@ -581,10 +560,7 @@ class CardanoWallet extends Bip39Wallet { } on NodeTorMismatchConfigException { rethrow; } catch (e, s) { - Logging.instance.logd( - "Error updating transactions in cardano_wallet.dart: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error updating transactions in cardano_wallet.dart: ", error: e, stackTrace: s); } } diff --git a/lib/wallets/wallet/impl/dash_wallet.dart b/lib/wallets/wallet/impl/dash_wallet.dart index 559581256..59fdaa037 100644 --- a/lib/wallets/wallet/impl/dash_wallet.dart +++ b/lib/wallets/wallet/impl/dash_wallet.dart @@ -212,7 +212,7 @@ class DashWallet extends Bip39HDWallet .fold(BigInt.zero, (value, element) => value + element); TransactionType type; - final TransactionSubType subType = TransactionSubType.none; + const TransactionSubType subType = TransactionSubType.none; // At least one input was owned by this wallet. if (wasSentFromThisWallet) { @@ -234,10 +234,8 @@ class DashWallet extends Bip39HDWallet // Only found outputs owned by this wallet. type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } diff --git a/lib/wallets/wallet/impl/dogecoin_wallet.dart b/lib/wallets/wallet/impl/dogecoin_wallet.dart index 52946f170..e9046f959 100644 --- a/lib/wallets/wallet/impl/dogecoin_wallet.dart +++ b/lib/wallets/wallet/impl/dogecoin_wallet.dart @@ -214,7 +214,7 @@ class DogecoinWallet .fold(BigInt.zero, (value, element) => value + element); TransactionType type; - final TransactionSubType subType = TransactionSubType.none; + const TransactionSubType subType = TransactionSubType.none; // At least one input was owned by this wallet. if (wasSentFromThisWallet) { @@ -237,10 +237,8 @@ class DogecoinWallet // Only found outputs owned by this wallet. type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } diff --git a/lib/wallets/wallet/impl/ecash_wallet.dart b/lib/wallets/wallet/impl/ecash_wallet.dart index 27ec2e8bd..a8741ba21 100644 --- a/lib/wallets/wallet/impl/ecash_wallet.dart +++ b/lib/wallets/wallet/impl/ecash_wallet.dart @@ -276,10 +276,8 @@ class EcashWallet extends Bip39HDWallet // only found outputs owned by this wallet type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } @@ -332,10 +330,11 @@ class EcashWallet extends Bip39HDWallet } } catch (e, s) { // Probably doesn't contain a cash token so just log failure - Logging.instance.logd( + Logging.instance.w( "Script pub key \"$scriptPubKeyHex\" cash token" " parsing check failed: $e\n$s", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); } diff --git a/lib/wallets/wallet/impl/epiccash_wallet.dart b/lib/wallets/wallet/impl/epiccash_wallet.dart index 11b4973bb..10238cef6 100644 --- a/lib/wallets/wallet/impl/epiccash_wallet.dart +++ b/lib/wallets/wallet/impl/epiccash_wallet.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:decimal/decimal.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_libepiccash/lib.dart' as epiccash; import 'package:flutter_libepiccash/models/transaction.dart' as epic_models; import 'package:isar/isar.dart'; @@ -93,13 +92,12 @@ class EpiccashWallet extends Bip39Wallet { wallet: wallet, transactionId: txSlateId, ); - Logging.instance.logd( + Logging.instance.d( "cancel $txSlateId result: $result", - level: LogLevel.Info, ); return result; } catch (e, s) { - Logging.instance.logd("$e, $s", level: LogLevel.Error); + Logging.instance.e("", error: e, stackTrace: s); return e.toString(); } } @@ -192,19 +190,18 @@ class EpiccashWallet extends Bip39Wallet { (Decimal.parse(transactionFees.fee.toString())).toBigInt().toInt(); } catch (e, s) { //todo: come back to this - debugPrint("$e $s"); + Logging.instance.e("Error getting fees", error: e, stackTrace: s); } return realFee; } catch (e, s) { - Logging.instance - .logd("Error getting fees $e - $s", level: LogLevel.Error); + Logging.instance.e("Error getting fees $e - $s", error: e, stackTrace: s); rethrow; } } Future _startSync() async { _hackedCheckTorNodePrefs(); - Logging.instance.logd("request start sync", level: LogLevel.Info); + Logging.instance.d("request start sync"); final wallet = await secureStorageInterface.read(key: '${walletId}_wallet'); const int refreshFromNode = 1; if (!syncMutex.isLocked) { @@ -217,7 +214,7 @@ class EpiccashWallet extends Bip39Wallet { ); }); } else { - Logging.instance.logd("request start sync denied", level: LogLevel.Info); + Logging.instance.d("request start sync denied"); } } @@ -257,10 +254,11 @@ class EpiccashWallet extends Bip39Wallet { ); return response is String && response.contains("Challenge"); - } catch (_) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.w( "_testEpicBoxConnection failed on \"$host:$port\"", - level: LogLevel.Info, + error: e, + stackTrace: s, ); return false; } finally { @@ -289,8 +287,7 @@ class EpiccashWallet extends Bip39Wallet { ); return true; } catch (e, s) { - Logging.instance - .logd("ERROR STORING ADDRESS $e $s", level: LogLevel.Error); + Logging.instance.e("ERROR STORING ADDRESS", error: e, stackTrace: s); return false; } } @@ -302,7 +299,7 @@ class EpiccashWallet extends Bip39Wallet { // of the last one that has not been processed, or the index after the one most recently processed; return receivingIndex; } catch (e, s) { - Logging.instance.logd("$e $s", level: LogLevel.Error); + Logging.instance.e("$e $s", error: e, stackTrace: s); return 0; } } @@ -341,9 +338,8 @@ class EpiccashWallet extends Bip39Wallet { epicboxConfig: epicboxConfig.toString(), ); - Logging.instance.logd( + Logging.instance.d( "WALLET_ADDRESS_IS $walletAddress", - level: LogLevel.Info, ); final address = Address( @@ -379,9 +375,8 @@ class EpiccashWallet extends Bip39Wallet { // loop while scanning in chain in chunks (of blocks?) while (lastScannedBlock < chainHeight) { - Logging.instance.logd( + Logging.instance.d( "chainHeight: $chainHeight, lastScannedBlock: $lastScannedBlock", - level: LogLevel.Info, ); final int nextScannedBlock = await epiccash.LibEpiccash.scanOutputs( @@ -406,24 +401,17 @@ class EpiccashWallet extends Bip39Wallet { lastScannedBlock = nextScannedBlock; } - Logging.instance.logd( - "_startScans successfully at the tip", - level: LogLevel.Info, - ); + Logging.instance.d("_startScans successfully at the tip"); //Once scanner completes restart listener await _listenToEpicbox(); } catch (e, s) { - Logging.instance.logd( - "_startScans failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("_startScans failed: ", error: e, stackTrace: s); rethrow; } } Future _listenToEpicbox() async { - Logging.instance - .logd("STARTING WALLET LISTENER ....", level: LogLevel.Info); + Logging.instance.d("STARTING WALLET LISTENER ...."); final wallet = await secureStorageInterface.read(key: '${walletId}_wallet'); final EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig(); epiccash.LibEpiccash.startEpicboxListener( @@ -550,9 +538,8 @@ class EpiccashWallet extends Bip39Wallet { ); } else { try { - Logging.instance.logd( + Logging.instance.d( "initializeExisting() ${cryptoCurrency.prettyName} wallet", - level: LogLevel.Info, ); final config = await _getRealConfig(); @@ -571,10 +558,8 @@ class EpiccashWallet extends Bip39Wallet { await updateNode(); } catch (e, s) { // do nothing, still allow user into wallet - Logging.instance.logd( - "$runtimeType init() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .w("$runtimeType init() failed: ", error: e, stackTrace: s); } } } @@ -637,10 +622,7 @@ class EpiccashWallet extends Bip39Wallet { txid: transaction.slateId, ); } catch (e, s) { - Logging.instance.logd( - "Epic cash confirmSend: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Epic cash confirmSend: ", error: e, stackTrace: s); rethrow; } } @@ -681,8 +663,7 @@ class EpiccashWallet extends Bip39Wallet { fee: feeAmount, ); } catch (e, s) { - Logging.instance - .logd("Epic cash prepareSend: $e\n$s", level: LogLevel.Error); + Logging.instance.e("Epic cash prepareSend", error: e, stackTrace: s); rethrow; } } @@ -764,9 +745,10 @@ class EpiccashWallet extends Bip39Wallet { unawaited(refresh(doScan: false)); }); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from electrumx_mixin recover(): $e\n$s", - level: LogLevel.Info, + Logging.instance.e( + "Exception rethrown from electrumx_mixin recover(): ", + error: e, + stackTrace: s, ); rethrow; @@ -867,7 +849,7 @@ class EpiccashWallet extends Bip39Wallet { // } }); } - } catch (error, strace) { + } catch (e, s) { GlobalEventBus.instance.fire( NodeConnectionStatusChangedEvent( NodeConnectionStatus.disconnected, @@ -882,9 +864,10 @@ class EpiccashWallet extends Bip39Wallet { cryptoCurrency, ), ); - Logging.instance.logd( - "Caught exception in refreshWalletData(): $error\n$strace", - level: LogLevel.Error, + Logging.instance.e( + "Caught exception in refreshWalletData()", + error: e, + stackTrace: s, ); } finally { refreshMutex.release(); @@ -920,9 +903,10 @@ class EpiccashWallet extends Bip39Wallet { isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "Epic cash wallet failed to update balance: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Epic cash wallet failed to update balance: ", + error: e, + stackTrace: s, ); } } @@ -1060,10 +1044,11 @@ class EpiccashWallet extends Bip39Wallet { await mainDB.isar.transactionV2s.putAll(txns); }); } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "${cryptoCurrency.runtimeType} ${cryptoCurrency.network} net wallet" - " \"${info.name}\"_${info.walletId} updateTransactions() failed: $e\n$s", - level: LogLevel.Warning, + " \"${info.name}\"_${info.walletId} updateTransactions() failed", + error: e, + stackTrace: s, ); } } @@ -1107,7 +1092,11 @@ class EpiccashWallet extends Bip39Wallet { ) != null; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Info); + Logging.instance.e( + "", + error: e, + stackTrace: s, + ); return false; } } @@ -1164,8 +1153,7 @@ class EpiccashWallet extends Bip39Wallet { timer?.cancel(); timer = null; await super.exit(); - Logging.instance - .logd("EpicCash_wallet exit finished", level: LogLevel.Info); + Logging.instance.d("EpicCash_wallet exit finished"); } void _hackedCheckTorNodePrefs() { @@ -1219,7 +1207,7 @@ Future deleteEpicWallet({ config: config!, ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Error); + Logging.instance.e("$e\n$s", error: e, stackTrace: s); return "deleteEpicWallet($walletId) failed..."; } } diff --git a/lib/wallets/wallet/impl/ethereum_wallet.dart b/lib/wallets/wallet/impl/ethereum_wallet.dart index 6551f8eda..e61da1df6 100644 --- a/lib/wallets/wallet/impl/ethereum_wallet.dart +++ b/lib/wallets/wallet/impl/ethereum_wallet.dart @@ -240,9 +240,10 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType wallet failed to update balance: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "$runtimeType wallet failed to update balance: ", + error: e, + stackTrace: s, ); } } @@ -258,9 +259,10 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType Exception caught in chainHeight: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "$runtimeType Exception caught in chainHeight: ", + error: e, + stackTrace: s, ); } } @@ -297,10 +299,9 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { ); if (response.value == null) { - Logging.instance.logd( + Logging.instance.w( "Failed to refresh transactions for ${cryptoCurrency.prettyName} ${info.name} " "$walletId: ${response.exception}", - level: LogLevel.Warning, ); return; } @@ -407,10 +408,9 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { } await mainDB.updateOrPutTransactionV2s(txns); } else { - Logging.instance.logd( + Logging.instance.w( "Failed to refresh transactions with nonces for ${cryptoCurrency.prettyName} " "${info.name} $walletId: ${txsResponse.exception}", - level: LogLevel.Warning, ); } } diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index 055127c50..9aa1357f0 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -60,9 +60,8 @@ class FiroWallet extends Bip39HDWallet if (txData.tempTx != null) { await mainDB.updateOrPutTransactionV2s([txData.tempTx!]); _unconfirmedTxids.add(txData.tempTx!.txid); - Logging.instance.logd( + Logging.instance.d( "Added firo unconfirmed: ${txData.tempTx!.txid}", - level: LogLevel.Info, ); } return txData; @@ -221,17 +220,15 @@ class FiroWallet extends Bip39HDWallet ); if (isMySpark && sparkCoinsInvolvedReceived.isEmpty && !isMySpentSpark) { - Logging.instance.logd( + Logging.instance.e( "sparkCoinsInvolvedReceived is empty and should not be! (ignoring tx parsing)", - level: LogLevel.Error, ); continue; } if (isMySpentSpark && sparkCoinsInvolvedSpent.isEmpty && !isMySpark) { - Logging.instance.logd( + Logging.instance.e( "sparkCoinsInvolvedSpent is empty and should not be! (ignoring tx parsing)", - level: LogLevel.Error, ); continue; } @@ -248,15 +245,13 @@ class FiroWallet extends Bip39HDWallet } else if (asm.startsWith("OP_LELANTUSMINT")) { isMint = true; } else { - Logging.instance.logd( + Logging.instance.d( "Unknown mint op code found for lelantusmint tx: ${txData["txid"]}", - level: LogLevel.Error, ); } } else { - Logging.instance.logd( + Logging.instance.d( "ASM for lelantusmint tx: ${txData["txid"]} is null!", - level: LogLevel.Error, ); } } @@ -268,15 +263,13 @@ class FiroWallet extends Bip39HDWallet asm.startsWith("OP_SPARKSMINT")) { isSparkMint = true; } else { - Logging.instance.logd( + Logging.instance.d( "Unknown mint op code found for sparkmint tx: ${txData["txid"]}", - level: LogLevel.Error, ); } } else { - Logging.instance.logd( + Logging.instance.d( "ASM for sparkmint tx: ${txData["txid"]} is null!", - level: LogLevel.Error, ); } } @@ -570,10 +563,8 @@ class FiroWallet extends Bip39HDWallet // only found outputs owned by this wallet type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } @@ -747,10 +738,7 @@ class FiroWallet extends Bip39HDWallet ); // receiving addresses - Logging.instance.logd( - "checking receiving addresses...", - level: LogLevel.Info, - ); + Logging.instance.d("checking receiving addresses..."); final canBatch = await serverCanBatch; @@ -772,10 +760,7 @@ class FiroWallet extends Bip39HDWallet } // change addresses - Logging.instance.logd( - "checking change addresses...", - level: LogLevel.Info, - ); + Logging.instance.d("checking change addresses..."); for (final type in cryptoCurrency.supportedDerivationPathTypes) { changeFutures.add( canBatch @@ -899,15 +884,15 @@ class FiroWallet extends Bip39HDWallet }); unawaited(refresh()); - Logging.instance.logd( + Logging.instance.i( "Firo recover for " "${info.name}: ${DateTime.now().difference(start)}", - level: LogLevel.Info, ); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from electrumx_mixin recover(): $e\n$s", - level: LogLevel.Info, + Logging.instance.e( + "Exception rethrown from electrumx_mixin recover(): ", + error: e, + stackTrace: s, ); rethrow; diff --git a/lib/wallets/wallet/impl/litecoin_wallet.dart b/lib/wallets/wallet/impl/litecoin_wallet.dart index 073fe1149..034056817 100644 --- a/lib/wallets/wallet/impl/litecoin_wallet.dart +++ b/lib/wallets/wallet/impl/litecoin_wallet.dart @@ -287,10 +287,8 @@ class LitecoinWallet // } } } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } diff --git a/lib/wallets/wallet/impl/namecoin_wallet.dart b/lib/wallets/wallet/impl/namecoin_wallet.dart index cc92b32e3..5eb54b33b 100644 --- a/lib/wallets/wallet/impl/namecoin_wallet.dart +++ b/lib/wallets/wallet/impl/namecoin_wallet.dart @@ -264,10 +264,8 @@ class NamecoinWallet // Only found outputs owned by this wallet. type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } diff --git a/lib/wallets/wallet/impl/particl_wallet.dart b/lib/wallets/wallet/impl/particl_wallet.dart index a03068738..80db6e2ef 100644 --- a/lib/wallets/wallet/impl/particl_wallet.dart +++ b/lib/wallets/wallet/impl/particl_wallet.dart @@ -291,7 +291,7 @@ class ParticlWallet .fold(BigInt.zero, (value, element) => value + element); TransactionType type; - final TransactionSubType subType = TransactionSubType.none; + const TransactionSubType subType = TransactionSubType.none; // Particl has special outputs like confidential amounts. We can check // for them here. They're also checked in checkBlockUTXO. @@ -313,10 +313,8 @@ class ParticlWallet // Only found outputs owned by this wallet. type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } @@ -348,10 +346,7 @@ class ParticlWallet required TxData txData, required List utxoSigningData, }) async { - Logging.instance.logd( - "Starting Particl buildTransaction ----------", - level: LogLevel.Info, - ); + Logging.instance.d("Starting Particl buildTransaction ----------"); // TODO: use coinlib (For this we need coinlib to support particl) @@ -523,10 +518,8 @@ class ParticlWallet ); } } catch (e, s) { - Logging.instance.logd( - "Caught exception while signing transaction: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Caught exception while signing transaction: ", + error: e, stackTrace: s); rethrow; } @@ -540,9 +533,9 @@ class ParticlWallet String hexString = builtTx.toHex(isParticl: true).toString(); if (hexString.length % 2 != 0) { // Ensure the string has an even length. - Logging.instance.logd( + Logging.instance.e( "Hex string has odd length, which is unexpected.", - level: LogLevel.Error, + stackTrace: StackTrace.current, ); throw Exception("Invalid hex string length."); } diff --git a/lib/wallets/wallet/impl/peercoin_wallet.dart b/lib/wallets/wallet/impl/peercoin_wallet.dart index ef0ae1c71..153131415 100644 --- a/lib/wallets/wallet/impl/peercoin_wallet.dart +++ b/lib/wallets/wallet/impl/peercoin_wallet.dart @@ -272,10 +272,8 @@ class PeercoinWallet // Only found outputs owned by this wallet. type = TransactionType.incoming; } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.e("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } diff --git a/lib/wallets/wallet/impl/solana_wallet.dart b/lib/wallets/wallet/impl/solana_wallet.dart index fdf369da9..8ae0db348 100644 --- a/lib/wallets/wallet/impl/solana_wallet.dart +++ b/lib/wallets/wallet/impl/solana_wallet.dart @@ -99,10 +99,7 @@ class SolanaWallet extends Bip39Wallet { await mainDB.updateOrPutAddresses([address]); } } catch (e, s) { - Logging.instance.logd( - "$runtimeType checkSaveInitialReceivingAddress() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType checkSaveInitialReceivingAddress() failed: ", error: e, stackTrace: s); } } @@ -157,10 +154,7 @@ class SolanaWallet extends Bip39Wallet { ), ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType Solana prepareSend failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType Solana prepareSend failed: ", error: e, stackTrace: s); rethrow; } } @@ -197,10 +191,7 @@ class SolanaWallet extends Bip39Wallet { txid: txid, ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType Solana confirmSend failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType Solana confirmSend failed: ", error: e, stackTrace: s); rethrow; } } @@ -259,10 +250,7 @@ class SolanaWallet extends Bip39Wallet { health = await _rpcClient?.getHealth(); return health != null; } catch (e, s) { - Logging.instance.logd( - "$runtimeType Solana pingCheck failed \"health response=$health\": $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType Solana pingCheck failed \"health response=$health\": $e\n$s"); return Future.value(false); } } @@ -334,10 +322,7 @@ class SolanaWallet extends Bip39Wallet { await info.updateBalance(newBalance: newBalance, isar: mainDB.isar); } catch (e, s) { - Logging.instance.logd( - "Error getting balance in solana_wallet.dart: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error getting balance in solana_wallet.dart: ", error: e, stackTrace: s); } } @@ -354,11 +339,8 @@ class SolanaWallet extends Bip39Wallet { isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "Error occurred in solana_wallet.dart while getting" - " chain height for solana: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in solana_wallet.dart while getting" + " chain height for solana: $e\n$s"); } } @@ -458,11 +440,8 @@ class SolanaWallet extends Bip39Wallet { } on NodeTorMismatchConfigException { rethrow; } catch (e, s) { - Logging.instance.logd( - "Error occurred in solana_wallet.dart while getting" - " transactions for solana: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Error occurred in solana_wallet.dart while getting" + " transactions for solana: $e\n$s"); } } diff --git a/lib/wallets/wallet/impl/stellar_wallet.dart b/lib/wallets/wallet/impl/stellar_wallet.dart index 7d4b5880c..811858546 100644 --- a/lib/wallets/wallet/impl/stellar_wallet.dart +++ b/lib/wallets/wallet/impl/stellar_wallet.dart @@ -172,10 +172,10 @@ class StellarWallet extends Bip39Wallet { exists = true; } } catch (e, s) { - Logging.instance.logd( - "Error getting account ${e.toString()} - ${s.toString()}", - level: LogLevel.Error, - ); + Logging.instance.e( + "Error getting account ${e.toString()} - ${s.toString()}", + error: e, + stackTrace: s); } return exists; } @@ -230,10 +230,10 @@ class StellarWallet extends Bip39Wallet { } } catch (e, s) { // do nothing, still allow user into wallet - Logging.instance.logd( - "$runtimeType checkSaveInitialReceivingAddress() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e( + "$runtimeType checkSaveInitialReceivingAddress() failed: ", + error: e, + stackTrace: s); } } @@ -266,10 +266,8 @@ class StellarWallet extends Bip39Wallet { ), ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType prepareSend() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("$runtimeType prepareSend() failed: ", error: e, stackTrace: s); rethrow; } } @@ -327,7 +325,7 @@ class StellarWallet extends Bip39Wallet { txid: response.hash!, ); } catch (e, s) { - Logging.instance.logd("Error sending TX $e - $s", level: LogLevel.Error); + Logging.instance.e("Error sending TX $e - $s", error: e, stackTrace: s); rethrow; } } @@ -394,10 +392,9 @@ class StellarWallet extends Bip39Wallet { // probably just doesn't have any history yet or whatever stellar needs return; } else { - Logging.instance.logd( + Logging.instance.w( "$runtimeType ${info.name} $walletId " "failed to fetch account to updateBalance", - level: LogLevel.Warning, ); rethrow; } @@ -428,10 +425,11 @@ class StellarWallet extends Bip39Wallet { } } } catch (e, s) { - Logging.instance.logd( + Logging.instance.w( "$runtimeType ${info.name} $walletId " "updateBalance() failed: $e\n$s", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); rethrow; } @@ -448,10 +446,8 @@ class StellarWallet extends Bip39Wallet { .then((value) => value.records!.first.sequence); await info.updateCachedChainHeight(newHeight: height, isar: mainDB.isar); } catch (e, s) { - Logging.instance.logd( - "$runtimeType updateChainHeight() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType updateChainHeight() failed: ", + error: e, stackTrace: s); rethrow; } @@ -485,9 +481,8 @@ class StellarWallet extends Bip39Wallet { // probably just doesn't have any history yet or whatever stellar needs return; } else { - Logging.instance.logd( + Logging.instance.w( "Stellar ${info.name} $walletId failed to fetch transactions", - level: LogLevel.Warning, ); rethrow; } @@ -676,10 +671,8 @@ class StellarWallet extends Bip39Wallet { await mainDB.updateOrPutTransactionV2s(transactionList); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from updateTransactions(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Exception rethrown from updateTransactions(): ", + error: e, stackTrace: s); rethrow; } } diff --git a/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart b/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart index 624b66347..845b0282b 100644 --- a/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart +++ b/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart @@ -153,10 +153,8 @@ class EthTokenWallet extends Wallet { usingContractAddress: contractAddress.hex, ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType _updateTokenABI(): $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance + .w("$runtimeType _updateTokenABI(): ", error: e, stackTrace: s); } try { @@ -200,10 +198,8 @@ class EthTokenWallet extends Wallet { _sendFunction = _deployedContract.function('transfer'); } catch (e, s) { - Logging.instance.logd( - "$runtimeType wallet failed init(): $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance + .w("$runtimeType wallet failed init(): ", error: e, stackTrace: s); } } @@ -311,9 +307,9 @@ class EthTokenWallet extends Wallet { try { throw Exception(); } catch (_, s) { - Logging.instance.logd( - "Eth token wallet recover called. This should not happen. Stacktrace: $s", - level: LogLevel.Warning, + Logging.instance.w( + "Eth token wallet recover called. This should not happen.", + stackTrace: s, ); } } @@ -347,15 +343,15 @@ class EthTokenWallet extends Wallet { isar: mainDB.isar, ); } else { - Logging.instance.logd( + Logging.instance.w( "CachedEthTokenBalance.fetchAndUpdateCachedBalance failed: ${response.exception}", - level: LogLevel.Warning, ); } } catch (e, s) { - Logging.instance.logd( - "$runtimeType wallet failed to update balance: $e\n$s", - level: LogLevel.Warning, + Logging.instance.e( + "$runtimeType wallet failed to update balance: ", + error: e, + stackTrace: s, ); } } @@ -380,9 +376,8 @@ class EthTokenWallet extends Wallet { if (response.exception != null && response.exception!.message .contains("response is empty but status code is 200")) { - Logging.instance.logd( + Logging.instance.d( "No ${tokenContract.name} transfers found for $addressString", - level: LogLevel.Info, ); return; } @@ -415,13 +410,19 @@ class EthTokenWallet extends Wallet { extra: txExtra, ), ); - } catch (_) { + } catch (e, s) { // Server indexing failed for some reason. Instead of hard crashing or // showing no transactions we just skip it here. Not ideal but better // than nothing showing up - Logging.instance.logd( + Logging.instance.e( + "Server error: Transaction hash not found.", + error: e, + stackTrace: s, + ); + Logging.instance.d( "Server error: Transaction ${tokenDto.transactionHash} not found.", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } } @@ -523,9 +524,10 @@ class EthTokenWallet extends Wallet { } await mainDB.updateOrPutTransactionV2s(txns); } catch (e, s) { - Logging.instance.logd( - "$runtimeType wallet failed to update transactions: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "$runtimeType wallet failed to update transactions: ", + error: e, + stackTrace: s, ); } } diff --git a/lib/wallets/wallet/impl/tezos_wallet.dart b/lib/wallets/wallet/impl/tezos_wallet.dart index d0c837302..992a900ae 100644 --- a/lib/wallets/wallet/impl/tezos_wallet.dart +++ b/lib/wallets/wallet/impl/tezos_wallet.dart @@ -60,9 +60,10 @@ class TezosWallet extends Bip39Wallet { return Tezos.standardDerivationPath; } catch (e, s) { - Logging.instance.logd( - "Error in _scanPossiblePaths() in tezos_wallet.dart: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Error in _scanPossiblePaths() in tezos_wallet.dart: ", + error: e, + stackTrace: s, ); rethrow; } @@ -144,9 +145,10 @@ class TezosWallet extends Bip39Wallet { return opList; } catch (e, s) { - Logging.instance.logd( - "Error in _buildSendTransaction() in tezos_wallet.dart: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Error in _buildSendTransaction() in tezos_wallet.dart: ", + error: e, + stackTrace: s, ); rethrow; } @@ -164,9 +166,10 @@ class TezosWallet extends Bip39Wallet { } } catch (e, s) { // do nothing, still allow user into wallet - Logging.instance.logd( - "$runtimeType checkSaveInitialReceivingAddress() failed: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "$runtimeType checkSaveInitialReceivingAddress() failed: ", + error: e, + stackTrace: s, ); } } @@ -271,9 +274,10 @@ class TezosWallet extends Bip39Wallet { tezosOperationsList: opList, ); } catch (e, s) { - Logging.instance.logd( - "Error in prepareSend() in tezos_wallet.dart: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Error in prepareSend() in tezos_wallet.dart: ", + error: e, + stackTrace: s, ); if (e @@ -338,16 +342,16 @@ class TezosWallet extends Bip39Wallet { } catch (e, s) { if (_estCount > 3) { _estCount = 0; - Logging.instance.logd( - " Error in _estimate in tezos_wallet.dart: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + " Error in _estimate in tezos_wallet.dart: ", + error: e, + stackTrace: s, ); rethrow; } else { _estCount++; - Logging.instance.logd( + Logging.instance.e( "_estimate() retry _estCount=$_estCount", - level: LogLevel.Warning, ); return await _estimate( account, @@ -386,9 +390,10 @@ class TezosWallet extends Bip39Wallet { return fee; } catch (e, s) { - Logging.instance.logd( - " Error in estimateFeeFor() in tezos_wallet.dart: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + " Error in estimateFeeFor() in tezos_wallet.dart: ", + error: e, + stackTrace: s, ); rethrow; } @@ -499,9 +504,10 @@ class TezosWallet extends Bip39Wallet { await info.updateBalance(newBalance: newBalance, isar: mainDB.isar); } catch (e, s) { - Logging.instance.logd( - "Error getting balance in tezos_wallet.dart: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Error getting balance in tezos_wallet.dart: ", + error: e, + stackTrace: s, ); } } @@ -523,10 +529,11 @@ class TezosWallet extends Bip39Wallet { isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Error occurred in tezos_wallet.dart while getting" - " chain height for tezos: $e\n$s", - level: LogLevel.Error, + " chain height for tezos", + error: e, + stackTrace: s, ); } } diff --git a/lib/wallets/wallet/intermediate/lib_monero_wallet.dart b/lib/wallets/wallet/intermediate/lib_monero_wallet.dart index 2e965cb6d..5d176ec7d 100644 --- a/lib/wallets/wallet/intermediate/lib_monero_wallet.dart +++ b/lib/wallets/wallet/intermediate/lib_monero_wallet.dart @@ -179,7 +179,11 @@ abstract class LibMoneroWallet onNewBlock: onNewBlock, onBalancesChanged: onBalancesChanged, onError: (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w( + "$e\n$s", + error: e, + stackTrace: s, + ); }, ), ); @@ -307,7 +311,7 @@ abstract class LibMoneroWallet privateSpendKey: base.getPrivateSpendKey(), ); } catch (e, s) { - Logging.instance.logd("getKeys failed: $e\n$s", level: LogLevel.Fatal); + Logging.instance.f("getKeys failed: ", error: e, stackTrace: s); return CWKeyData( walletId: walletId, publicViewKey: "ERROR", @@ -374,7 +378,7 @@ abstract class LibMoneroWallet value: "", ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Fatal); + Logging.instance.f("", error: e, stackTrace: s); } await updateNode(); } @@ -462,7 +466,7 @@ abstract class LibMoneroWallet isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Fatal); + Logging.instance.f("", error: e, stackTrace: s); rethrow; } await updateNode(); @@ -476,10 +480,8 @@ abstract class LibMoneroWallet libMoneroWallet?.startListeners(); libMoneroWallet?.startAutoSaving(); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from recoverFromMnemonic(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Exception rethrown from recoverFromMnemonic(): ", + error: e, stackTrace: s); rethrow; } }); @@ -548,10 +550,8 @@ abstract class LibMoneroWallet _setSyncStatus(lib_monero_compat.ConnectedSyncStatus()); } catch (e, s) { _setSyncStatus(lib_monero_compat.FailedSyncStatus()); - Logging.instance.logd( - "Exception caught in $runtimeType.updateNode(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Exception caught in $runtimeType.updateNode(): ", + error: e, stackTrace: s); } return; @@ -733,6 +733,7 @@ abstract class LibMoneroWallet @override Future exit() async { + Logging.instance.i("exit called on $walletId"); libMoneroWallet?.stopAutoSaving(); libMoneroWallet?.stopListeners(); libMoneroWallet?.stopSyncing(); @@ -802,10 +803,7 @@ abstract class LibMoneroWallet await updateBalance(); await updateTransactions(); } catch (e, s) { - Logging.instance.logd( - "onBalancesChanged(): $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("onBalancesChanged(): ", error: e, stackTrace: s); } } @@ -813,10 +811,7 @@ abstract class LibMoneroWallet try { await updateTransactions(); } catch (e, s) { - Logging.instance.logd( - "onNewBlock(): $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("onNewBlock(): ", error: e, stackTrace: s); } } @@ -1165,10 +1160,8 @@ abstract class LibMoneroWallet isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "Exception in generateNewAddress(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Exception in generateNewAddress(): ", error: e, stackTrace: s); } } @@ -1178,10 +1171,10 @@ abstract class LibMoneroWallet try { throw Exception(); } catch (_, s) { - Logging.instance.logd( - "checkReceivingAddressForTransactions called but reuse address flag set: $s", - level: LogLevel.Error, - ); + Logging.instance.e( + "checkReceivingAddressForTransactions called but reuse address flag set: $s", + error: e, + stackTrace: s); } } @@ -1230,16 +1223,16 @@ abstract class LibMoneroWallet } } } on SocketException catch (se, s) { - Logging.instance.logd( - "SocketException caught in _checkReceivingAddressForTransactions(): $se\n$s", - level: LogLevel.Error, - ); + Logging.instance.e( + "SocketException caught in _checkReceivingAddressForTransactions(): $se\n$s", + error: e, + stackTrace: s); return; } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from _checkReceivingAddressForTransactions(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e( + "Exception rethrown from _checkReceivingAddressForTransactions(): ", + error: e, + stackTrace: s); rethrow; } } @@ -1386,10 +1379,8 @@ abstract class LibMoneroWallet throw ArgumentError("Invalid fee rate argument provided!"); } } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from prepare send(): $e\n$s", - level: LogLevel.Info, - ); + Logging.instance.i("Exception rethrown from prepare send(): ", + error: e, stackTrace: s); if (e.toString().contains("Incorrect unlocked balance")) { throw Exception("Insufficient balance!"); @@ -1407,23 +1398,20 @@ abstract class LibMoneroWallet txData.pendingTransaction!, ); - Logging.instance.logd( + Logging.instance.d( "transaction ${txData.pendingTransaction!.txid} has been sent", - level: LogLevel.Info, ); return txData.copyWith(txid: txData.pendingTransaction!.txid); } catch (e, s) { - Logging.instance.logd( - "${info.name} ${compatType.name.toLowerCase()} confirmSend: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e( + "${info.name} ${compatType.name.toLowerCase()} confirmSend: ", + error: e, + stackTrace: s); rethrow; } } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Info, - ); + Logging.instance.e("Exception rethrown from confirmSend(): ", + error: e, stackTrace: s); rethrow; } } @@ -1499,10 +1487,8 @@ abstract class LibMoneroWallet libMoneroWallet?.startListeners(); libMoneroWallet?.startAutoSaving(); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from recoverViewOnly(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Exception rethrown from recoverViewOnly(): ", + error: e, stackTrace: s); rethrow; } }); diff --git a/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart b/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart index 4e634ba17..c11eb2fbc 100644 --- a/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart +++ b/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart @@ -18,10 +18,7 @@ extension EpiccashWalletInfoExtension on WalletInfo { ), ); } catch (e, s) { - Logging.instance.logd( - "ExtraEpiccashWalletInfo.fromMap failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("ExtraEpiccashWalletInfo.fromMap failed: ", error: e, stackTrace: s); return null; } } diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index accbfea55..36cec7b85 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -126,7 +126,11 @@ abstract class Wallet { await updateChainHeight(); } catch (e, s) { // do nothing on failure (besides logging) - Logging.instance.logd("$e\n$s", level: LogLevel.Warning); + Logging.instance.w( + "$e\n$s", + error: e, + stackTrace: s, + ); } // return regardless of whether it was updated or not as we want a @@ -238,6 +242,13 @@ abstract class Wallet { .walletIdEqualTo(walletId) .findFirst(); + Logging.instance.i( + "Wallet.load loading" + " $walletId " + "${walletInfo?.coin.identifier}" + " ${walletInfo?.name}", + ); + if (walletInfo == null) { throw Exception( "WalletInfo not found for $walletId when trying to call Wallet.load()", @@ -537,7 +548,7 @@ abstract class Wallet { }); } }, - onError: (Object error, StackTrace strace) { + onError: (Object e, StackTrace s) { GlobalEventBus.instance.fire( NodeConnectionStatusChangedEvent( NodeConnectionStatus.disconnected, @@ -552,9 +563,10 @@ abstract class Wallet { cryptoCurrency, ), ); - Logging.instance.logd( - "Caught exception in refreshWalletData(): $error\n$strace", - level: LogLevel.Error, + Logging.instance.e( + "Caught exception in refreshWalletData()", + error: e, + stackTrace: s, ); }, ); @@ -699,15 +711,15 @@ abstract class Wallet { ); } - Logging.instance.logd( + Logging.instance.i( "Refresh for " - "${info.name}: ${DateTime.now().difference(start)}", - level: LogLevel.Info, + "$walletId::${info.name}: ${DateTime.now().difference(start)}", ); } } Future exit() async { + Logging.instance.i("exit called on $walletId"); _periodicRefreshTimer?.cancel(); _networkAliveTimer?.cancel(); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart index 4205d32bd..371236180 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart @@ -20,8 +20,7 @@ mixin BCashInterface required TxData txData, required List utxoSigningData, }) async { - Logging.instance - .logd("Starting buildTransaction ----------", level: LogLevel.Info); + Logging.instance.d("Starting buildTransaction ----------"); // TODO: use coinlib @@ -114,10 +113,8 @@ mixin BCashInterface ); } } catch (e, s) { - Logging.instance.logd( - "Caught exception while signing transaction: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("Caught exception while signing transaction: ", + error: e, stackTrace: s); rethrow; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart index 6bdce0b5e..5a24f32ca 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart @@ -379,7 +379,7 @@ mixin CashFusionInterface return root.derivePath(derivationPath).privateKey.data; } catch (e, s) { - Logging.instance.logd("$e\n$s", level: LogLevel.Fatal); + Logging.instance.f("", error: e, stackTrace: s); throw Exception("Derivation path for pubkey=$pubKey could not be found"); } } @@ -741,9 +741,8 @@ mixin CashFusionInterface if (addr == null) { // A utxo object should always have a non null address. // If non found then just ignore the UTXO (aka don't fuse it) - Logging.instance.logd( + Logging.instance.d( "Ignoring utxo=$utxo for address=\"$addressString\" while selecting UTXOs for Fusion", - level: LogLevel.Info, ); continue; } @@ -781,10 +780,7 @@ mixin CashFusionInterface // Also reset the failed count here. _failedFuseCount = 0; } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("", error: e, stackTrace: s); // just continue on attempt failure // Increment the number of failed fusion rounds. @@ -816,10 +812,7 @@ mixin CashFusionInterface } } } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("", error: e, stackTrace: s); // Stop the fusion process and update the UI state. await _mainFusionObject?.stop(); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index 66522fe7b..d4b387b8d 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -113,8 +113,7 @@ mixin ElectrumXInterface int additionalOutputs = 0, List? utxos, }) async { - Logging.instance - .logd("Starting coinSelection ----------", level: LogLevel.Info); + Logging.instance.d("Starting coinSelection ----------"); // TODO: multiple recipients one day assert(txData.recipients!.length == 1); @@ -171,22 +170,19 @@ mixin ElectrumXInterface ); } - Logging.instance.logd( + Logging.instance.d( "spendableOutputs.length: ${spendableOutputs.length}", - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( "availableOutputs.length: ${availableOutputs.length}", - level: LogLevel.Info, ); - Logging.instance - .logd("spendableOutputs: $spendableOutputs", level: LogLevel.Info); - Logging.instance.logd( + Logging.instance.d("spendableOutputs: $spendableOutputs"); + Logging.instance.d( "spendableSatoshiValue: $spendableSatoshiValue", - level: LogLevel.Info, ); - Logging.instance.logd("satoshiAmountToSend: $satoshiAmountToSend", - level: LogLevel.Info); + Logging.instance.d( + "satoshiAmountToSend: $satoshiAmountToSend", + ); BigInt satoshisBeingUsed = BigInt.zero; int inputsBeingConsumed = 0; @@ -216,12 +212,11 @@ mixin ElectrumXInterface inputsBeingConsumed = spendableOutputs.length; } - Logging.instance - .logd("satoshisBeingUsed: $satoshisBeingUsed", level: LogLevel.Info); - Logging.instance.logd("inputsBeingConsumed: $inputsBeingConsumed", - level: LogLevel.Info); - Logging.instance - .logd('utxoObjectsToUse: $utxoObjectsToUse', level: LogLevel.Info); + Logging.instance.d("satoshisBeingUsed: $satoshisBeingUsed"); + Logging.instance.d( + "inputsBeingConsumed: $inputsBeingConsumed", + ); + Logging.instance.d('utxoObjectsToUse: $utxoObjectsToUse'); // numberOfOutputs' length must always be equal to that of recipientsArray and recipientsAmtArray final List recipientsArray = [recipientAddress]; @@ -260,8 +255,8 @@ mixin ElectrumXInterface ), )) .vSize!; - } catch (e) { - Logging.instance.logd("vSizeForOneOutput: $e", level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e("vSizeForOneOutput: $e", error: e, stackTrace: s); rethrow; } @@ -286,8 +281,8 @@ mixin ElectrumXInterface ), )) .vSize!; - } catch (e) { - Logging.instance.logd("vSizeForTwoOutPuts: $e", level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e("vSizeForTwoOutPuts: $e", error: e, stackTrace: s); rethrow; } @@ -310,33 +305,27 @@ mixin ElectrumXInterface ), ); - Logging.instance.logd( + Logging.instance.d( "feeForTwoOutputs: $feeForTwoOutputs", - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( "feeForOneOutput: $feeForOneOutput", - level: LogLevel.Info, ); final difference = satoshisBeingUsed - satoshiAmountToSend; Future singleOutputTxn() async { - Logging.instance.logd( + Logging.instance.d( 'Input size: $satoshisBeingUsed', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Fee being paid: $difference sats', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Estimated fee: $feeForOneOutput', - level: LogLevel.Info, ); final txnData = await buildTransaction( utxoSigningData: utxoSigningData, @@ -358,12 +347,11 @@ mixin ElectrumXInterface // no change output required if (difference == feeForOneOutput) { - Logging.instance.logd('1 output in tx', level: LogLevel.Info); + Logging.instance.d('1 output in tx'); return await singleOutputTxn(); } else if (difference < feeForOneOutput) { - Logging.instance.logd( + Logging.instance.w( 'Cannot pay tx fee - checking for more outputs and trying again', - level: LogLevel.Warning, ); // try adding more outputs if (spendableOutputs.length > inputsBeingConsumed) { @@ -394,27 +382,12 @@ mixin ElectrumXInterface recipientsArray.add(newChangeAddress); recipientsAmtArray.add(changeOutputSize); - Logging.instance.logd('2 outputs in tx', level: LogLevel.Info); - Logging.instance.logd( - 'Input size: $satoshisBeingUsed', - level: LogLevel.Info, - ); - Logging.instance.logd( - 'Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info, - ); - Logging.instance.logd( - 'Change Output Size: $changeOutputSize', - level: LogLevel.Info, - ); - Logging.instance.logd( - 'Difference (fee being paid): $feeBeingPaid sats', - level: LogLevel.Info, - ); - Logging.instance.logd( - 'Estimated fee: $feeForTwoOutputs', - level: LogLevel.Info, - ); + Logging.instance.d('2 outputs in tx'); + Logging.instance.d('Input size: $satoshisBeingUsed'); + Logging.instance.d('Recipient output size: $satoshiAmountToSend'); + Logging.instance.d('Change Output Size: $changeOutputSize'); + Logging.instance.d('Difference (fee being paid): $feeBeingPaid sats'); + Logging.instance.d('Estimated fee: $feeForTwoOutputs'); TxData txnData = await buildTransaction( utxoSigningData: utxoSigningData, @@ -433,25 +406,20 @@ mixin ElectrumXInterface recipientsAmtArray.removeLast(); recipientsAmtArray.add(changeOutputSize); - Logging.instance.logd( + Logging.instance.d( 'Adjusted Input size: $satoshisBeingUsed', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Adjusted Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Adjusted Change Output Size: $changeOutputSize', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Adjusted Difference (fee being paid): $feeBeingPaid sats', - level: LogLevel.Info, ); - Logging.instance.logd( + Logging.instance.d( 'Adjusted Estimated fee: $feeForTwoOutputs', - level: LogLevel.Info, ); txnData = await buildTransaction( @@ -475,9 +443,8 @@ mixin ElectrumXInterface } else { // Something went wrong here. It either overshot or undershot the estimated fee amount or the changeOutputSize // is smaller than or equal to cryptoCurrency.dustLimit. Revert to single output transaction. - Logging.instance.logd( + Logging.instance.d( 'Reverting to 1 output in tx', - level: LogLevel.Info, ); return await singleOutputTxn(); @@ -497,8 +464,7 @@ mixin ElectrumXInterface required int? satsPerVByte, required int feeRatePerKB, }) async { - Logging.instance - .logd("Attempting to send all $cryptoCurrency", level: LogLevel.Info); + Logging.instance.d("Attempting to send all $cryptoCurrency"); if (txData.recipients!.length != 1) { throw Exception( "Send all to more than one recipient not yet supported", @@ -628,8 +594,11 @@ mixin ElectrumXInterface return signingData; } catch (e, s) { - Logging.instance - .logd("fetchBuildTxData() threw: $e,\n$s", level: LogLevel.Error); + Logging.instance.e( + "fetchBuildTxData() threw", + error: e, + stackTrace: s, + ); rethrow; } } @@ -639,8 +608,7 @@ mixin ElectrumXInterface required TxData txData, required List utxoSigningData, }) async { - Logging.instance - .logd("Starting buildTransaction ----------", level: LogLevel.Info); + Logging.instance.d("Starting buildTransaction ----------"); // temp tx data to show in gui while waiting for real data from server final List tempInputs = []; @@ -810,9 +778,10 @@ mixin ElectrumXInterface ); } } catch (e, s) { - Logging.instance.logd( - "Caught exception while signing transaction: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Caught exception while signing transaction: ", + error: e, + stackTrace: s, ); rethrow; } @@ -858,9 +827,10 @@ mixin ElectrumXInterface await electrumXClient.checkElectrumAdapter(); return await fetchChainHeight(retries: retries); } - Logging.instance.logd( + Logging.instance.e( "Exception rethrown in fetchChainHeight\nError: $e\nStack trace: $s", - level: LogLevel.Error, + error: e, + stackTrace: s, ); // completer.completeError(e, s); // return Future.error(e, s); @@ -891,9 +861,10 @@ mixin ElectrumXInterface } return result; } catch (e, s) { - Logging.instance.logd( - "Exception rethrown in _getBatchTxCount(address: $addresses: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown in _getBatchTxCount(address: $addresses: ", + error: e, + stackTrace: s, ); rethrow; } @@ -932,12 +903,15 @@ mixin ElectrumXInterface final newNode = await _getCurrentElectrumXNode(); try { await electrumXClient.closeAdapter(); - } catch (e) { + } catch (e, s) { if (e.toString().contains("initialized")) { // Ignore. This should happen every first time the wallet is opened. } else { - Logging.instance - .logd("Error closing electrumXClient: $e", level: LogLevel.Error); + Logging.instance.e( + "Error closing electrumXClient", + error: e, + stackTrace: s, + ); } } electrumXClient = ElectrumXClient.from( @@ -966,9 +940,8 @@ mixin ElectrumXInterface for (int index = 0; gapCounter < cryptoCurrency.maxUnusedAddressGap; index += txCountBatchSize) { - Logging.instance.logd( + Logging.instance.d( "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", - level: LogLevel.Info, ); final List txCountCallArgs = []; @@ -1053,9 +1026,8 @@ mixin ElectrumXInterface int index = 0; for (; gapCounter < cryptoCurrency.maxUnusedAddressGap; index++) { - Logging.instance.logd( + Logging.instance.d( "index: $index, \t GapCounter chain=$chain ${type.name}: $gapCounter", - level: LogLevel.Info, ); final derivePath = cryptoCurrency.constructDerivePath( @@ -1177,10 +1149,8 @@ mixin ElectrumXInterface return allTxHashes; } catch (e, s) { - Logging.instance.logd( - "$runtimeType._fetchHistory: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("$runtimeType._fetchHistory: ", error: e, stackTrace: s); rethrow; } } @@ -1298,13 +1268,16 @@ mixin ElectrumXInterface ).raw.toInt(), ); - Logging.instance.logd("fetched fees: $feeObject", level: LogLevel.Info); + Logging.instance.d( + "fetched fees: $feeObject", + ); _cachedFees = feeObject; return _cachedFees!; } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Exception rethrown from _getFees(): $e\nStack trace: $s", - level: LogLevel.Error, + error: e, + stackTrace: s, ); if (_cachedFees == null) { rethrow; @@ -1375,9 +1348,10 @@ mixin ElectrumXInterface try { throw Exception(); } catch (_, s) { - Logging.instance.logd( + Logging.instance.e( "checkReceivingAddressForTransactions called but reuse address flag set: $s", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } } @@ -1411,11 +1385,9 @@ mixin ElectrumXInterface } } } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from _checkReceivingAddressForTransactions" - "($cryptoCurrency): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Exception rethrown from _checkReceivingAddressForTransactions" + "($cryptoCurrency): $e\n$s"); rethrow; } } @@ -1430,9 +1402,10 @@ mixin ElectrumXInterface try { throw Exception(); } catch (_, s) { - Logging.instance.logd( + Logging.instance.e( "checkChangeAddressForTransactions called but reuse address flag set: $s", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } } @@ -1463,11 +1436,9 @@ mixin ElectrumXInterface await checkChangeAddressForTransactions(); } } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from _checkChangeAddressForTransactions" - "($cryptoCurrency): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Exception rethrown from _checkChangeAddressForTransactions" + "($cryptoCurrency): $e\n$s"); rethrow; } } @@ -1503,9 +1474,8 @@ mixin ElectrumXInterface } // receiving addresses - Logging.instance.logd( + Logging.instance.e( "checking receiving addresses...", - level: LogLevel.Info, ); final canBatch = await serverCanBatch; @@ -1528,9 +1498,8 @@ mixin ElectrumXInterface } // change addresses - Logging.instance.logd( + Logging.instance.d( "checking change addresses...", - level: LogLevel.Info, ); for (final type in cryptoCurrency.supportedDerivationPathTypes) { changeFutures.add( @@ -1634,11 +1603,12 @@ mixin ElectrumXInterface paymentCodeStrings: codesToCheck, ); } catch (e, s) { - Logging.instance.logd( + Logging.instance.e( "Failed to check ${PaynymIsApi.baseURL} followers/following for history during " "bitcoin wallet ($walletId ${info.name}) " - "_recoverWalletFromBIP32SeedPhrase: $e/n$s", - level: LogLevel.Error, + "_recoverWalletFromBIP32SeedPhrase", + error: e, + stackTrace: s, ); } } @@ -1646,9 +1616,10 @@ mixin ElectrumXInterface unawaited(refresh()); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from electrumx_mixin recover(): $e\n$s", - level: LogLevel.Info, + Logging.instance.e( + "Exception rethrown from electrumx_mixin recover(): ", + error: e, + stackTrace: s, ); rethrow; @@ -1714,10 +1685,8 @@ mixin ElectrumXInterface return await mainDB.updateUTXOs(walletId, outputArray); } catch (e, s) { - Logging.instance.logd( - "Output fetch unsuccessful: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("Output fetch unsuccessful: ", error: e, stackTrace: s); return false; } } @@ -1725,13 +1694,16 @@ mixin ElectrumXInterface @override Future confirmSend({required TxData txData}) async { try { - Logging.instance - .logd("confirmSend txData: $txData", level: LogLevel.Info); + Logging.instance.d( + "confirmSend txData: $txData", + ); final txHash = await electrumXClient.broadcastTransaction( rawTx: txData.raw!, ); - Logging.instance.logd("Sent txHash: $txHash", level: LogLevel.Info); + Logging.instance.d( + "Sent txHash: $txHash", + ); txData = txData.copyWith( usedUTXOs: @@ -1746,9 +1718,10 @@ mixin ElectrumXInterface return await updateSentCachedTxData(txData: txData); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown from confirmSend(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -1798,8 +1771,7 @@ mixin ElectrumXInterface isSendAllCoinControlUtxos: isSendAllCoinControlUtxos, ); - Logging.instance - .logd("PREPARE SEND RESULT: $result", level: LogLevel.Info); + Logging.instance.d("PREPARE SEND RESULT: $result"); if (result.fee!.raw.toInt() < result.vSize!) { throw Exception( @@ -1847,7 +1819,9 @@ mixin ElectrumXInterface isSendAllCoinControlUtxos: isSendAllCoinControlUtxos, ); - Logging.instance.logd("prepare send: $result", level: LogLevel.Info); + Logging.instance.d( + "prepare send: $result", + ); if (result.fee!.raw.toInt() < result.vSize!) { throw Exception( "Error in fee calculation: Transaction fee (${result.fee!.raw.toInt()}) cannot " @@ -1859,9 +1833,10 @@ mixin ElectrumXInterface throw ArgumentError("Invalid fee rate argument provided!"); } } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from prepareSend(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown from prepareSend(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -1876,9 +1851,10 @@ mixin ElectrumXInterface await super.init(); } catch (e, s) { // do nothing, still allow user into wallet - Logging.instance.logd( - "$runtimeType init() did not complete: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "$runtimeType init() did not complete: ", + error: e, + stackTrace: s, ); } } @@ -1889,7 +1865,9 @@ mixin ElectrumXInterface .getServerFeatures() .timeout(const Duration(seconds: 5)); - Logging.instance.logd("features: $features", level: LogLevel.Info); + Logging.instance.d( + "features: $features", + ); _serverVersion = _parseServerVersion(features["server_version"] as String); @@ -1898,9 +1876,10 @@ mixin ElectrumXInterface throw Exception("Genesis hash does not match!"); } } catch (e, s) { - Logging.instance.logd( - "$runtimeType _initializeServerVersionAndCheckGenesisHash() did not complete: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "$runtimeType _initializeServerVersionAndCheckGenesisHash() did not complete: ", + error: e, + stackTrace: s, ); } } @@ -1968,9 +1947,8 @@ mixin ElectrumXInterface } } catch (_) {} - Logging.instance.logd( + Logging.instance.d( "${info.name} _parseServerVersion($version) => $result", - level: LogLevel.Info, ); return result; } @@ -2024,9 +2002,8 @@ mixin ElectrumXInterface if (root != null) { // receiving addresses - Logging.instance.logd( + Logging.instance.d( "checking receiving addresses...", - level: LogLevel.Info, ); final canBatch = await serverCanBatch; @@ -2058,9 +2035,8 @@ mixin ElectrumXInterface } // change addresses - Logging.instance.logd( + Logging.instance.d( "checking change addresses...", - level: LogLevel.Info, ); for (final type in cryptoCurrency.supportedDerivationPathTypes) { final path = cryptoCurrency.constructDerivePath( @@ -2185,9 +2161,10 @@ mixin ElectrumXInterface unawaited(refresh()); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from electrumx_mixin recoverViewOnly(): $e\n$s", - level: LogLevel.Info, + Logging.instance.e( + "Exception rethrown from electrumx_mixin recoverViewOnly(): ", + error: e, + stackTrace: s, ); rethrow; diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart index a51a98a22..148bd61a2 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart @@ -82,8 +82,9 @@ mixin LelantusInterface coin.mintIndex, privateKey, ); - } catch (_) { - Logging.instance.logd("error bad key", level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e("error bad key"); + Logging.instance.t("error bad key", error: e, stackTrace: s); return lelantus.DartLelantusEntry(1, 0, 0, 0, 0, ''); } }).toList(); @@ -153,10 +154,8 @@ mixin LelantusInterface chaincode: root.chaincode, ); - Logging.instance - .logd("prepared fee: ${result.fee}", level: LogLevel.Info); - Logging.instance - .logd("prepared vSize: ${result.vSize}", level: LogLevel.Info); + Logging.instance.d("prepared fee: ${result.fee}"); + Logging.instance.d("prepared vSize: ${result.vSize}"); // fee should never be less than vSize sanity check if (result.fee!.raw.toInt() < result.vSize!) { @@ -166,9 +165,10 @@ mixin LelantusInterface } return result; } catch (e, s) { - Logging.instance.logd( - "Exception rethrown in firo prepareSend(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown in firo prepareSend()", + error: e, + stackTrace: s, ); rethrow; } @@ -232,9 +232,10 @@ mixin LelantusInterface await mainDB.isar.lelantusCoins.put(jmint); }); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, + Logging.instance.e( + "", + error: e, + stackTrace: s, ); rethrow; } @@ -285,7 +286,7 @@ mixin LelantusInterface await mainDB.addNewTransactionData(txnsData, walletId); } else { // This is a mint - Logging.instance.logd("this is a mint", level: LogLevel.Info); + Logging.instance.t("this is a mint"); final List updatedCoins = []; @@ -310,9 +311,10 @@ mixin LelantusInterface await mainDB.isar.lelantusCoins.putAll(updatedCoins); }); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, + Logging.instance.e( + "", + error: e, + stackTrace: s, ); rethrow; } @@ -433,18 +435,20 @@ mixin LelantusInterface txs[address] = txn; } catch (e, s) { - Logging.instance.logd( - "Exception caught in getJMintTransactions(): $e\n$s", - level: LogLevel.Info, + Logging.instance.i( + "Exception caught in getJMintTransactions(): ", + error: e, + stackTrace: s, ); rethrow; } } return txs; } catch (e, s) { - Logging.instance.logd( - "Exception rethrown in getJMintTransactions(): $e\n$s", - level: LogLevel.Info, + Logging.instance.i( + "Exception rethrown in getJMintTransactions(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -471,9 +475,10 @@ mixin LelantusInterface } return sets; } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from refreshAnonymitySets: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown from refreshAnonymitySets: ", + error: e, + stackTrace: s, ); rethrow; } @@ -537,9 +542,11 @@ mixin LelantusInterface final tx = await mainDB.getTransaction(walletId, coin.txid); if (tx == null) { - Logging.instance.logd( + Logging.instance.e( + "Transaction with txid=REDACTED not found in local db!", + ); + Logging.instance.d( "Transaction with txid=${coin.txid} not found in local db!", - level: LogLevel.Error, ); } } @@ -556,9 +563,10 @@ mixin LelantusInterface await mainDB.isar.lelantusCoins.putAll(updatedCoins); }); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, + Logging.instance.f( + " ", + error: e, + stackTrace: s, ); rethrow; } @@ -639,9 +647,8 @@ mixin LelantusInterface } if (inputTxns.isEmpty) { //some error. - Logging.instance.logd( + Logging.instance.f( "cryptic \"//some error\" occurred in staticProcessRestore on lelantus coin: $coin", - level: LogLevel.Error, ); continue; } @@ -699,9 +706,10 @@ mixin LelantusInterface await mainDB.isar.lelantusCoins.putAll(result.lelantusCoins); }); } catch (e, s) { - Logging.instance.logd( - "$e\n$s", - level: LogLevel.Fatal, + Logging.instance.e( + "", + error: e, + stackTrace: s, ); // don't just rethrow since isar likes to strip stack traces for some reason throw Exception("e=$e & s=$s"); @@ -717,7 +725,7 @@ mixin LelantusInterface final spendTxs = await getJMintTransactions( result.spendTxIds, ); - Logging.instance.logd(spendTxs, level: LogLevel.Info); + Logging.instance.d("lelantus spendTxs: $spendTxs"); for (final element in spendTxs.entries) { final address = element.value.address.value ?? @@ -842,7 +850,7 @@ mixin LelantusInterface } for (final mintsElement in txData.mintsMapLelantus!) { - Logging.instance.logd("using $mintsElement", level: LogLevel.Info); + Logging.instance.d("using $mintsElement"); final Uint8List mintu8 = Format.stringToUint8List(mintsElement['script'] as String); txb.addOutput(mintu8, mintsElement['value'] as int); @@ -1064,9 +1072,10 @@ mixin LelantusInterface try { anonymitySets = await fetchAnonymitySets(); } catch (e, s) { - Logging.instance.logd( - "Firo needs better internet to create mints: $e\n$s", - level: LogLevel.Fatal, + Logging.instance.f( + "Firo needs better internet to create mints: ", + error: e, + stackTrace: s, ); rethrow; } @@ -1088,10 +1097,7 @@ mixin LelantusInterface } if (isUsedMintTag) { - Logging.instance.logd( - "Found used index when minting", - level: LogLevel.Warning, - ); + Logging.instance.d("Found used index when minting"); } if (!isUsedMintTag) { @@ -1136,9 +1142,10 @@ mixin LelantusInterface unawaited(refresh()); } catch (e, s) { - Logging.instance.logd( - "Exception caught in anonymizeAllLelantus(): $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Exception caught in anonymizeAllLelantus(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -1172,15 +1179,16 @@ mixin LelantusInterface .findFirstSync(); if (txn == null) { - Logging.instance.logd( + Logging.instance.e( + "Transaction not found in DB for lelantus coin", + ); + Logging.instance.d( "Transaction not found in DB for lelantus coin: $lelantusCoin", - level: LogLevel.Fatal, ); } else { if (txn.isLelantus != true) { - Logging.instance.logd( + Logging.instance.f( "Bad database state found in ${info.name} $walletId for _refreshBalance lelantus", - level: LogLevel.Fatal, ); } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart index 4bf55253d..1d725afb4 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart @@ -345,9 +345,10 @@ mixin NanoInterface on Bip39Wallet { } } catch (e, s) { // do nothing, still allow user into wallet - Logging.instance.logd( - "$runtimeType checkSaveInitialReceivingAddress() failed: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "$runtimeType checkSaveInitialReceivingAddress() failed: ", + error: e, + stackTrace: s, ); } } @@ -488,8 +489,11 @@ mixin NanoInterface on Bip39Wallet { txid: decoded["hash"].toString(), ); } catch (e, s) { - Logging.instance - .logd("Error sending transaction $e - $s", level: LogLevel.Error); + Logging.instance.e( + "Error sending transaction", + error: e, + stackTrace: s, + ); rethrow; } } @@ -669,9 +673,10 @@ mixin NanoInterface on Bip39Wallet { await info.updateBalance(newBalance: balance, isar: mainDB.isar); } catch (e, s) { - Logging.instance.logd( - "Failed to update ${cryptoCurrency.runtimeType} balance: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to update ${cryptoCurrency.runtimeType} balance: ", + error: e, + stackTrace: s, ); } } @@ -705,9 +710,10 @@ mixin NanoInterface on Bip39Wallet { await info.updateCachedChainHeight(newHeight: height, isar: mainDB.isar); } catch (e, s) { - Logging.instance.logd( - "Failed to update ${cryptoCurrency.runtimeType} chain height: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to update ${cryptoCurrency.runtimeType} chain height: ", + error: e, + stackTrace: s, ); } } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart index 09896d2d6..430c46c45 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart @@ -18,8 +18,8 @@ mixin OrdinalsInterface try { return (await _litescribeAPI.getInscriptionsByAddress(address)) .isNotEmpty; - } catch (_) { - Logging.instance.logd("Litescribe api failure!", level: LogLevel.Error); + } catch (e, s) { + Logging.instance.e("Litescribe api failure!", error: e, stackTrace: s); return false; } @@ -54,10 +54,8 @@ mixin OrdinalsInterface await mainDB.isar.ordinals.putAll(ords); }); } catch (e, s) { - Logging.instance.logd( - "$runtimeType failed refreshInscriptions(): $e\n$s", - level: LogLevel.Warning, - ); + Logging.instance.w("$runtimeType failed refreshInscriptions(): ", + error: e, stackTrace: s); } } // =================== Overrides ============================================= diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart index 1ad8aa986..9d1935bec 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart @@ -889,10 +889,7 @@ mixin PaynymInterface return Tuple2(clTx.toHex(), clTx.vSize()); } catch (e, s) { - Logging.instance.logd( - "_createNotificationTx(): $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("_createNotificationTx(): ", error: e, stackTrace: s); rethrow; } } @@ -901,18 +898,18 @@ mixin PaynymInterface required TxData txData, }) async { try { - Logging.instance - .logd("confirmNotificationTx txData: $txData", level: LogLevel.Info); + Logging.instance.d("confirmNotificationTx txData: $txData"); final txHash = await electrumXClient.broadcastTransaction(rawTx: txData.raw!); - Logging.instance.logd("Sent txHash: $txHash", level: LogLevel.Info); + Logging.instance.d("Sent txHash: $txHash"); try { await updateTransactions(); - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.e( "refresh() failed in confirmNotificationTx (${info.name}::$walletId): $e", - level: LogLevel.Error, + error: e, + stackTrace: s, ); } @@ -921,9 +918,10 @@ mixin PaynymInterface txHash: txHash, ); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown from confirmSend(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -1047,7 +1045,7 @@ mixin PaynymInterface return (witnessComponents[1] as String).toUint8ListFromHex; } } catch (e, s) { - Logging.instance.logd("_pubKeyFromInput: $e\n$s", level: LogLevel.Info); + Logging.instance.e("_pubKeyFromInput()", error: e, stackTrace: s); } } return null; @@ -1097,9 +1095,15 @@ mixin PaynymInterface return unBlindedPaymentCode; } catch (e, s) { - Logging.instance.logd( - "unBlindedPaymentCodeFromTransaction() failed: $e\n$s\nFor tx: $transaction", - level: LogLevel.Warning, + Logging.instance.e( + "unBlindedPaymentCodeFromTransaction()", + error: e, + stackTrace: s, + ); + Logging.instance.d( + "unBlindedPaymentCodeFromTransaction() failed for tx: $transaction", + error: e, + stackTrace: s, ); return null; } @@ -1148,10 +1152,16 @@ mixin PaynymInterface ); return unBlindedPaymentCode; - } catch (e) { - Logging.instance.logd( + } catch (e, s) { + Logging.instance.e( + "unBlindedPaymentCodeFromTransactionBad()n", + error: e, + stackTrace: s, + ); + Logging.instance.d( "unBlindedPaymentCodeFromTransactionBad() failed: $e\nFor tx: $transaction", - level: LogLevel.Warning, + error: e, + stackTrace: s, ); return null; } @@ -1826,10 +1836,8 @@ mixin PaynymInterface // TODO: [prio=none] Check for special Bitcoin outputs like ordinals. } else { - Logging.instance.logd( - "Unexpected tx found (ignoring it): $txData", - level: LogLevel.Error, - ); + Logging.instance.w("Unexpected tx found (ignoring it)"); + Logging.instance.d("Unexpected tx found (ignoring it): $txData"); continue; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/rbf_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/rbf_interface.dart index 939987bdd..2e609aeb0 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/rbf_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/rbf_interface.dart @@ -148,10 +148,7 @@ mixin RbfInterface ), ], ); - Logging.instance.logd( - "RBF on assumed send all", - level: LogLevel.Debug, - ); + Logging.instance.d("RBF on assumed send all"); return await prepareSend(txData: txData); } else if (txData.recipients!.where((e) => e.isChange).length == 1) { final newFee = BigInt.from(oldTransaction.vSize! * newRate); @@ -184,9 +181,8 @@ mixin RbfInterface isChange: removed.isChange, ), ); - Logging.instance.logd( + Logging.instance.d( "RBF with same utxo set with increased fee and reduced change", - level: LogLevel.Debug, ); } else { // new change amount is less than dust limit. @@ -198,9 +194,8 @@ mixin RbfInterface // oh well... // do nothing here as we already removed the change output above - Logging.instance.logd( + Logging.instance.d( "RBF with same utxo set with increased fee and no change", - level: LogLevel.Debug, ); } return await buildTransaction( @@ -255,10 +250,9 @@ mixin RbfInterface // TODO: remove assert assert(newUtxoSet.length == txData.utxos!.length + extraUtxos.length); - Logging.instance.logd( + Logging.instance.d( "RBF with ${extraUtxos.length} extra utxo(s)" " added to pay for the new fee", - level: LogLevel.Debug, ); return await buildTransaction( diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index fc34ed50e..347bf9f2c 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -179,10 +179,7 @@ mixin SparkInterface } } catch (e, s) { // do nothing, still allow user into wallet - Logging.instance.logd( - "$runtimeType init() failed: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance.e("$runtimeType init() failed", error: e, stackTrace: s); } // await info.updateReceivingAddress( @@ -759,13 +756,12 @@ mixin SparkInterface required TxData txData, }) async { try { - Logging.instance - .logd("confirmSend txData: $txData", level: LogLevel.Info); + Logging.instance.d("confirmSend txData: $txData"); final txHash = await electrumXClient.broadcastTransaction( rawTx: txData.raw!, ); - Logging.instance.logd("Sent txHash: $txHash", level: LogLevel.Info); + Logging.instance.d("Sent txHash: $txHash"); txData = txData.copyWith( // TODO revisit setting these both @@ -784,9 +780,10 @@ mixin SparkInterface return await updateSentCachedTxData(txData: txData); } catch (e, s) { - Logging.instance.logd( - "Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Exception rethrown from confirmSend(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -857,17 +854,17 @@ mixin SparkInterface } return result; - } catch (e) { - Logging.instance.logd( - "_refreshSparkCoinsMempoolCheck() failed: $e", - level: LogLevel.Error, + } catch (e, s) { + Logging.instance.e( + "_refreshSparkCoinsMempoolCheck() failed", + error: e, + stackTrace: s, ); return []; } finally { - Logging.instance.logd( + Logging.instance.d( "$walletId ${info.name} _refreshSparkCoinsMempoolCheck() run " "duration: ${DateTime.now().difference(start)}", - level: LogLevel.Debug, ); } } @@ -1168,16 +1165,13 @@ mixin SparkInterface isar: mainDB.isar, ); } catch (e, s) { - Logging.instance.logd( - "$runtimeType $walletId ${info.name}: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("$runtimeType $walletId ${info.name}: ", error: e, stackTrace: s); rethrow; } finally { - Logging.instance.logd( + Logging.instance.d( "${info.name} refreshSparkData() duration:" " ${DateTime.now().difference(start)}", - level: LogLevel.Debug, ); } } @@ -1213,10 +1207,8 @@ mixin SparkInterface try { await refreshSparkData(null); } catch (e, s) { - Logging.instance.logd( - "$runtimeType $walletId ${info.name}: $e\n$s", - level: LogLevel.Error, - ); + Logging.instance + .e("$runtimeType $walletId ${info.name}: ", error: e, stackTrace: s); rethrow; } } @@ -1747,9 +1739,10 @@ mixin SparkInterface ); } } catch (e, s) { - Logging.instance.logd( - "Caught exception while signing spark mint transaction: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Caught exception while signing spark mint transaction: ", + error: e, + stackTrace: s, ); rethrow; } @@ -1900,9 +1893,10 @@ mixin SparkInterface await confirmSparkMintTransactions(txData: TxData(sparkMints: mints)); } catch (e, s) { - Logging.instance.logd( - "Exception caught in anonymizeAllSpark(): $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Exception caught in anonymizeAllSpark(): ", + error: e, + stackTrace: s, ); rethrow; } @@ -2007,9 +2001,10 @@ mixin SparkInterface return txData.copyWith(sparkMints: mints); } catch (e, s) { - Logging.instance.logd( - "Exception caught in prepareSparkMintTransaction(): $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Exception caught in prepareSparkMintTransaction(): ", + error: e, + stackTrace: s, ); rethrow; } diff --git a/lib/widgets/desktop/qr_code_scanner_dialog.dart b/lib/widgets/desktop/qr_code_scanner_dialog.dart index 24d24c93d..53b21bb9c 100644 --- a/lib/widgets/desktop/qr_code_scanner_dialog.dart +++ b/lib/widgets/desktop/qr_code_scanner_dialog.dart @@ -61,7 +61,7 @@ class _QrCodeScannerDialogState extends State { try { if (Platform.isLinux && _cameraLinuxPlugin != null) { await _cameraLinuxPlugin.initializeCamera(); - Logging.instance.logd("Linux Camera initialized", level: LogLevel.Info); + Logging.instance.d("Linux Camera initialized"); } else if (Platform.isWindows && _cameraWindowsPlugin != null) { final List cameras = await _cameraWindowsPlugin.availableCameras(); @@ -81,9 +81,8 @@ class _QrCodeScannerDialogState extends State { await _cameraWindowsPlugin.initializeCamera(_cameraId); // await _cameraWindowsPlugin!.onCameraInitialized(_cameraId).first; // TODO [prio=low]: Make this work. ^^^ - Logging.instance.logd( + Logging.instance.d( "Windows Camera initialized with ID: $_cameraId", - level: LogLevel.Info, ); } else if (Platform.isMacOS) { final List videoDevices = await CameraMacOS.instance @@ -95,16 +94,18 @@ class _QrCodeScannerDialogState extends State { await CameraMacOS.instance .initialize(cameraMacOSMode: CameraMacOSMode.photo); - Logging.instance.logd( + Logging.instance.d( "macOS Camera initialized with ID: $_macOSDeviceId", - level: LogLevel.Info, ); } return true; } catch (e, s) { - Logging.instance - .logd("Failed to initialize camera: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "Failed to initialize camera", + error: e, + stackTrace: s, + ); return false; } } @@ -115,14 +116,11 @@ class _QrCodeScannerDialogState extends State { try { if (Platform.isLinux && _cameraLinuxPlugin != null) { _cameraLinuxPlugin.stopCamera(); - Logging.instance.logd("Linux Camera stopped", level: LogLevel.Info); + Logging.instance.d("Linux Camera stopped"); } else if (Platform.isWindows && _cameraWindowsPlugin != null) { // if (_cameraId >= 0) { await _cameraWindowsPlugin.dispose(_cameraId); - Logging.instance.logd( - "Windows Camera stopped with ID: $_cameraId", - level: LogLevel.Info, - ); + Logging.instance.d("Windows Camera stopped with ID: $_cameraId"); // } else { // Logging.instance.log("Windows Camera ID is null. Cannot dispose.", // level: LogLevel.Error); @@ -130,18 +128,18 @@ class _QrCodeScannerDialogState extends State { } else if (Platform.isMacOS) { // if (_macOSDeviceId != null) { await CameraMacOS.instance.stopImageStream(); - Logging.instance.logd( - "macOS Camera stopped with ID: $_macOSDeviceId", - level: LogLevel.Info, - ); + Logging.instance.d("macOS Camera stopped with ID: $_macOSDeviceId"); // } else { // Logging.instance.log("macOS Camera ID is null. Cannot stop.", // level: LogLevel.Error); // } } } catch (e, s) { - Logging.instance - .logd("Failed to stop camera: $e\n$s", level: LogLevel.Error); + Logging.instance.e( + "Failed to stop camera", + error: e, + stackTrace: s, + ); } } @@ -161,15 +159,13 @@ class _QrCodeScannerDialogState extends State { } else if (Platform.isMacOS) { final macOSimg = await CameraMacOS.instance.takePicture(); if (macOSimg == null) { - Logging.instance - .logd("Failed to capture image", level: LogLevel.Error); + Logging.instance.w("Failed to capture image"); await Future.delayed(Duration(milliseconds: _imageDelayInMs)); continue; } final img.Image? image = img.decodeImage(macOSimg.bytes!); if (image == null) { - Logging.instance - .logd("Failed to capture image", level: LogLevel.Error); + Logging.instance.w("Failed to capture image"); await Future.delayed(Duration(milliseconds: _imageDelayInMs)); continue; } @@ -187,8 +183,7 @@ class _QrCodeScannerDialogState extends State { // > WARNING Since this will check the image data against all known // > decoders, it is much slower than using an explicit decoder if (image == null) { - Logging.instance - .logd("Failed to decode image", level: LogLevel.Error); + Logging.instance.w("Failed to decode image"); await Future.delayed(Duration(milliseconds: _imageDelayInMs)); continue; } @@ -211,7 +206,7 @@ class _QrCodeScannerDialogState extends State { } break; } else { - // Logging.instance.log("No QR code found in the image", level: LogLevel.Info); + // Logging.instance.log("No QR code found in the image"); // if (mounted) { // widget.onSnackbar("No QR code found in the image."); // } @@ -220,7 +215,7 @@ class _QrCodeScannerDialogState extends State { await Future.delayed(Duration(milliseconds: _imageDelayInMs)); } catch (e) { - // Logging.instance.log("Failed to capture and scan image: $e\n$s", level: LogLevel.Error); + // Logging.instance.log("Failed to capture and scan image", error: e, stackTrace: s,); // Spammy. // if (mounted) { @@ -252,7 +247,7 @@ class _QrCodeScannerDialogState extends State { } return qrDecode.text; } catch (e) { - // Logging.instance.log("Failed to decode QR code: $e\n$s", level: LogLevel.Error); + // Logging.instance.log("Failed to decode QR code", error: e, stackTrace: s,); // Spammy. return null; } @@ -361,9 +356,10 @@ class _QrCodeScannerDialogState extends State { } } } catch (e, s) { - Logging.instance.logd( - "Failed to decode image: $e\n$s", - level: LogLevel.Error, + Logging.instance.e( + "Failed to decode image: ", + error: e, + stackTrace: s, ); if (context.mounted) { await showFloatingFlushBar( diff --git a/lib/widgets/log_level_preference_widget.dart b/lib/widgets/log_level_preference_widget.dart index 7a889564d..0e8b713c3 100644 --- a/lib/widgets/log_level_preference_widget.dart +++ b/lib/widgets/log_level_preference_widget.dart @@ -65,14 +65,16 @@ class _LogLevelPreferenceWidgetState _levels[_sliderValue.toInt()]; }, ), - if (current == Level.debug || current == Level.trace) + if (current == Level.debug || + current == Level.trace || + current == Level.info) Padding( padding: const EdgeInsets.only(top: 10), child: RoundedContainer( color: Theme.of(context).extension()!.warningBackground, - child: RichText( - text: TextSpan( + child: SelectableText.rich( + TextSpan( text: "Privacy Warning: ", style: STextStyles.label700(context).copyWith( color: Theme.of(context) @@ -119,11 +121,29 @@ class _LogLevelPreferenceWidgetState ), TextSpan( text: " may log sensitive metadata, such as transaction" - " details, addresses, or network activity. While no" - " private keys, mnemonics, or credentials will ever " - "be logged, enabling these levels could expose " - "information that might compromise privacy if " - "accessed by unauthorized parties.", + " details, amounts, addresses, or network activity. While ", + style: STextStyles.label(context).copyWith( + color: Theme.of(context) + .extension()! + .warningForeground, + fontSize: Util.isDesktop ? 14 : 12, + ), + ), + TextSpan( + text: "Info", + style: STextStyles.label700(context).copyWith( + color: Theme.of(context) + .extension()! + .warningForeground, + fontSize: Util.isDesktop ? 14 : 12, + ), + ), + TextSpan( + text: " logs are less likely to contain sensitive data, " + "they may still include some. No private keys, " + "mnemonics, or credentials will ever be logged, but " + "enabling these levels could expose information that " + "might compromise privacy if accessed by unauthorized parties.", style: STextStyles.label(context).copyWith( color: Theme.of(context) .extension()! diff --git a/lib/widgets/textfields/frost_step_field.dart b/lib/widgets/textfields/frost_step_field.dart index 125100bf7..3c86f1fed 100644 --- a/lib/widgets/textfields/frost_step_field.dart +++ b/lib/widgets/textfields/frost_step_field.dart @@ -97,10 +97,7 @@ class _FrostStepFieldState extends State { ); if (qrResult == null) { - Logging.instance.logd( - "Qr scanning cancelled", - level: LogLevel.Info, - ); + Logging.instance.d("Qr scanning cancelled"); } else { // TODO [prio=low]: Validate QR code data. widget.controller.text = qrResult; @@ -109,9 +106,10 @@ class _FrostStepFieldState extends State { } } } on PlatformException catch (e, s) { - Logging.instance.logd( - "Failed to get camera permissions while trying to scan qr code: $e\n$s", - level: LogLevel.Warning, + Logging.instance.w( + "Failed to get camera permissions while trying to scan qr code: ", + error: e, + stackTrace: s, ); } } diff --git a/lib/widgets/wallet_card.dart b/lib/widgets/wallet_card.dart index c01b46614..4981dafaf 100644 --- a/lib/widgets/wallet_card.dart +++ b/lib/widgets/wallet_card.dart @@ -159,9 +159,8 @@ class SimpleWalletCard extends ConsumerWidget { if (!success!) { // TODO: show error dialog here? - Logging.instance.logd( + Logging.instance.e( "Failed to load token wallet for $contract", - level: LogLevel.Error, ); return; }