Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

🔊 Introduce new Logging framework. #964

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/infrastructure/rpc/awc_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:aewallet/util/universal_platform.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:logging/logging.dart';
import 'package:stream_channel/stream_channel.dart';

class AWCWebview extends StatefulWidget {
Expand Down Expand Up @@ -130,7 +131,7 @@ class WebviewMessagePortStreamChannel
with StreamChannelMixin<String>
implements StreamChannel<String> {
WebviewMessagePortStreamChannel({required this.port}) {
print('Wallet Init WebMessage PortStreamchannel');
logger.info('Wallet Init WebMessage PortStreamchannel');

port.setWebMessageCallback((message) {
if (message == null) return;
Expand All @@ -141,6 +142,7 @@ class WebviewMessagePortStreamChannel
port.postMessage(WebMessage(data: event));
});
}
static final logger = Logger('AWCBrowserExtension');

final IWebMessagePort port;
final _in = StreamController<String>(sync: true);
Expand Down
52 changes: 31 additions & 21 deletions lib/infrastructure/rpc/browser_extension_aws.web.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// ignore_for_file: avoid_web_libraries_in_flutter, avoid_print
// ignore_for_file: avoid_web_libraries_in_flutter

import 'dart:async';
import 'dart:js';

import 'package:aewallet/infrastructure/rpc/awc_json_rpc_server.dart';
import 'package:aewallet/infrastructure/rpc/browser_extension_aws.js.dart';
import 'package:logging/logging.dart';
import 'package:stream_channel/stream_channel.dart';

class BrowserExtensionAWS {
BrowserExtensionAWS() {
print('[AWCBrowserExtension] Init');
logger.info('Init');
_interopConnectionReceived = allowInterop(_connectionReceived);
}
static const logName = 'Browser RPC Server';
static final logger = Logger('Browser RPC Server');

static bool get isPlatformCompatible => isWebBrowserExtension;

Expand All @@ -22,42 +23,46 @@ class BrowserExtensionAWS {

late Function(BrowserExtensionPort port) _interopConnectionReceived;
void _connectionReceived(BrowserExtensionPort port) {
print('[AWCBrowserExtension] external connection received ');
logger.info('external connection received');
port.postMessage('connected');
final channel = BrowserExtensionMessagePortStreamChannel(port: port);
final peerServer = AWCJsonRPCServer(channel.cast<String>());
_peerServers.add(peerServer);

port.onDisconnect.addListener(allowInterop((_) async {
print('[AWCBrowserExtension] external connection closed ');
await peerServer.close();
_peerServers.remove(peerServer);
}));
port.onDisconnect.addListener(
allowInterop((_) async {
logger.info('external connection closed');
await peerServer.close();
_peerServers.remove(peerServer);
}),
);

unawaited(peerServer.listen());
}

Future<void> run() async => runZonedGuarded(
() async {
if (_isRunning) {
print('[AWCBrowserExtension] Already running. Cancel `start`');
logger.info('Already running. Cancel `start`');

return;
}

print('[AWCBrowserExtension] Starting');
logger.info('Starting');

onConnectExternal.addListener(_interopConnectionReceived);
_isRunning = true;
},
(error, stack) {
print(
'[AWCBrowserExtension] failed : $error',
logger.severe(
'failed',
error,
stack,
);
},
);

Future<void> stop() async {
print('[AWCBrowserExtension] Stopping');
logger.info('Stopping');
_isRunning = false;
onConnectExternal.removeListener(_interopConnectionReceived);
for (final peerServer in _peerServers) {
Expand All @@ -71,34 +76,39 @@ class BrowserExtensionMessagePortStreamChannel
with StreamChannelMixin<String>
implements StreamChannel<String> {
BrowserExtensionMessagePortStreamChannel({required this.port}) {
print('Wallet Init WebMessage PortStreamchannel');
logger.info('Wallet Init WebMessage PortStreamchannel');

port.onMessage.addListener(
allowInterop((message, _) {
if (message == null) return;
print('Wallet message received $message');
logger.info('Wallet message received $message');

_in.add(message);
print('Wallet message received done $message');
logger.info('Wallet message received done $message');
}),
);

_out.onCancel = close;

_outSubscription = _out.stream.listen((event) {
print('Wallet response sent $event');
logger.info('Wallet response sent $event');

port.postMessage(event);
});
}

static final logger = Logger('Browser RPC Server - StreamChannel');

Future<void> close() async {
print('Wallet releases port');
logger.info('Wallet releases port');

_out.onCancel = null;
await _outSubscription.cancel();
await _out.close();
port.disconnect();

await _in.close();
print('Wallet port release done');
logger.info('Wallet releases done');
}

final BrowserExtensionPort port;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/menu/settings/settings_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:aewallet/application/authentication/authentication.dart';
import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/dapps.dart';
import 'package:aewallet/application/device_abilities.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/language.dart';
import 'package:aewallet/application/settings/primary_currency.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/settings/version.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/domain/models/dapp.dart';
import 'package:aewallet/domain/repositories/features_flags.dart';
import 'package:aewallet/infrastructure/datasources/tokens_list.hive.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/accounts/layouts/account_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'dart:ui';

import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/model/data/account.dart';
import 'package:aewallet/ui/views/accounts/layouts/components/account_list_item.dart';
import 'package:aewallet/ui/views/main/home_page.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'dart:async';
import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/contact.dart';
import 'package:aewallet/application/market_price.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/language.dart';
import 'package:aewallet/application/settings/primary_currency.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/bus/transaction_send_event.dart';
import 'package:aewallet/model/available_language.dart';
import 'package:aewallet/model/data/account.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/add_account/bloc/provider.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// SPDX-License-Identifier: AGPL-3.0-or-later

import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/bus/transaction_send_event.dart';
import 'package:aewallet/domain/models/transaction.dart';
import 'package:aewallet/domain/repositories/transaction_remote.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/views/authenticate/auth_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AuthFactory {

switch (authMethod.method) {
case AuthMethod.yubikeyWithYubicloud:
// TODO : Generate a key with Yubikey
// TODO(Chralu): Generate a key with Yubikey
auth = await _authenticateWithYubikey(
context,
canCancel: canCancel,
Expand All @@ -72,7 +72,7 @@ class AuthFactory {
);
break;
case AuthMethod.pin:
// TODO : Use pin as key
// TODO(Chralu): Use pin as key
auth = await _authenticateWithPin(
context,
canCancel: canCancel,
Expand All @@ -81,7 +81,7 @@ class AuthFactory {
: null;
break;
case AuthMethod.biometrics:
// TODO : Generate a key with Biometrics
// TODO(Chralu): Generate a key with Biometrics
final hasBiometrics = await sl.get<BiometricUtil>().hasBiometrics();
if (hasBiometrics) {
auth = await _authenticateWithBiometrics(context)
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/authenticate/countdown_lock_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CountdownLockOverlay with LockOverlayMixin {

class _CountdownLockScreen extends ConsumerWidget
implements SheetSkeletonInterface {
const _CountdownLockScreen({super.key});
const _CountdownLockScreen();

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/authenticate/lock_mask_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LockMaskOverlay with LockOverlayMixin {
}

class _LockMask extends StatelessWidget {
const _LockMask({super.key});
const _LockMask();

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/intro/layouts/intro_backup_confirm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:async';

import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/recovery_phrase_saved.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/bus/authenticated_event.dart';
import 'package:aewallet/bus/transaction_send_event.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/main/components/main_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'dart:ui';
import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/device_abilities.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/ui/menu/settings/settings_sheet.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/main/components/nft_search_bar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/device_abilities.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
import 'package:aewallet/ui/util/dimens.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/main/components/recovery_phrase_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:core';

import 'package:aewallet/application/authentication/authentication.dart';
import 'package:aewallet/application/recovery_phrase_saved.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/ui/util/info_banner.dart';
import 'package:aewallet/ui/views/authenticate/auth_factory.dart';
import 'package:aewallet/ui/views/settings/backupseed_sheet.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/main/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/contact.dart';
import 'package:aewallet/application/migrations/migration_manager.dart';
import 'package:aewallet/application/notification/providers.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/repositories/features_flags.dart';
import 'package:aewallet/domain/repositories/notifications_repository.dart';
import 'package:aewallet/local_data_migration_widget.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/messenger/bloc/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'dart:async';
import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/contact.dart';
import 'package:aewallet/application/notification/providers.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/models/core/failures.dart';
import 'package:aewallet/domain/models/core/result.dart';
import 'package:aewallet/domain/repositories/messenger_repository.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:aewallet/application/device_abilities.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
import 'package:aewallet/ui/util/formatters.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/nft_creation/bloc/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'dart:typed_data';

import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/bus/transaction_send_event.dart';
import 'package:aewallet/domain/models/token.dart';
import 'package:aewallet/domain/models/token_property.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/models/core/result.dart';
import 'package:aewallet/domain/rpc/commands/command.dart';
import 'package:aewallet/domain/rpc/commands/send_transaction.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:aewallet/application/account/providers.dart';
import 'package:aewallet/application/connectivity_status.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/models/core/result.dart';
import 'package:aewallet/domain/rpc/command_dispatcher.dart';
import 'package:aewallet/domain/rpc/commands/add_service.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/models/core/result.dart';
import 'package:aewallet/domain/rpc/command_dispatcher.dart';
import 'package:aewallet/domain/rpc/commands/command.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/models/core/result.dart';
import 'package:aewallet/domain/rpc/command_dispatcher.dart';
import 'package:aewallet/domain/rpc/commands/command.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/domain/models/core/result.dart';
import 'package:aewallet/domain/rpc/command_dispatcher.dart';
import 'package:aewallet/domain/rpc/commands/command.dart';
Expand Down
Loading
Loading