Skip to content

Commit

Permalink
updated logger
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Oct 17, 2023
1 parent 8320f9a commit 3f289d1
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/apis/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Core implements ICore {
late IHeartBeat heartbeat;

Logger _logger = Logger(
level: Level.nothing,
level: Level.off,
printer: PrettyPrinter(),
);
@override
Expand Down
6 changes: 3 additions & 3 deletions lib/apis/core/pairing/pairing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class Pairing implements IPairing {
int? ttl,
EncodeOptions? encodeOptions,
}) async {
core.logger.v(
core.logger.t(
'pairing sendResult, id: $id topic: $topic, method: $method, params: $params, ttl: $ttl',
);

Expand Down Expand Up @@ -467,7 +467,7 @@ class Pairing implements IPairing {
dynamic result, {
EncodeOptions? encodeOptions,
}) async {
core.logger.v(
core.logger.t(
'pairing sendResult, id: $id topic: $topic, method: $method, result: $result',
);
final Map<String, dynamic> payload =
Expand Down Expand Up @@ -502,7 +502,7 @@ class Pairing implements IPairing {
JsonRpcError error, {
EncodeOptions? encodeOptions,
}) async {
core.logger.v(
core.logger.t(
'pairing sendError, id: $id topic: $topic, method: $method, error: $error',
);

Expand Down
12 changes: 6 additions & 6 deletions lib/apis/core/relay_client/relay_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class RelayClient implements IRelayClient {
/// PRIVATE FUNCTIONS ///
Future<void> _connect({String? relayUrl}) async {
core.logger.v('RelayClient Internal: Connecting to relay');
core.logger.t('RelayClient Internal: Connecting to relay');
if (isConnected) {
return;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ class RelayClient implements IRelayClient {
}

Future<void> _disconnect() async {
core.logger.v('RelayClient Internal: Disconnecting from relay');
core.logger.t('RelayClient Internal: Disconnecting from relay');
_active = false;

final bool shouldBroadcastDisonnect = isConnected;
Expand All @@ -235,7 +235,7 @@ class RelayClient implements IRelayClient {
_connecting = true;
_active = true;
var auth = await core.crypto.signJWT(core.relayUrl);
core.logger.v('Signed JWT: $auth');
core.logger.t('Signed JWT: $auth');
try {
final String url = WalletConnectUtils.formatRelayRpcUrl(
protocol: WalletConnectConstants.CORE_PROTOCOL,
Expand All @@ -251,7 +251,7 @@ class RelayClient implements IRelayClient {
jsonRPC = null;
}

core.logger.v('Initializing WebSocket with $url');
core.logger.t('Initializing WebSocket with $url');
await socketHandler.setup(
url: url,
);
Expand Down Expand Up @@ -358,7 +358,7 @@ class RelayClient implements IRelayClient {
void _heartbeatSubscription(EventArgs? args) async {
core.logger.i('RelayClient heartbeat received');
if (jsonRPC != null && jsonRPC!.isClosed) {
core.logger.v('RelayClient, WebSocket closed, reconnecting');
core.logger.t('RelayClient, WebSocket closed, reconnecting');
await connect();
}
}
Expand All @@ -370,7 +370,7 @@ class RelayClient implements IRelayClient {
/// JSON RPC MESSAGE HANDLERS
Future<bool> handlePublish(String topic, String message) async {
core.logger.v('Handling Publish Message: $topic, $message');
core.logger.t('Handling Publish Message: $topic, $message');
// If we want to ignore the message, stop
if (await _shouldIgnoreMessageEvent(topic, message)) {
core.logger.w('Ignoring Message: $topic, $message');
Expand Down
10 changes: 7 additions & 3 deletions lib/apis/sign_api/sign_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,11 @@ class SignEngine implements ISignEngine {
await core.pairing.disconnect(topic: topic);
}
} on WalletConnectError catch (error, s) {
core.logger.e('[$runtimeType] disconnectSession()', error, s);
core.logger.e(
'[$runtimeType] disconnectSession()',
error: error,
stackTrace: s,
);
}
}

Expand Down Expand Up @@ -885,7 +889,7 @@ class SignEngine implements ISignEngine {
JsonRpcRequest payload,
) async {
try {
core.logger.v(
core.logger.t(
'_onSessionProposeRequest, topic: $topic, payload: $payload',
);
final proposeRequest = WcSessionProposeRequest.fromJson(payload.params);
Expand Down Expand Up @@ -917,7 +921,7 @@ class SignEngine implements ISignEngine {
);
} on WalletConnectError catch (err) {
// If they aren't, send an error
core.logger.v(
core.logger.t(
'_onSessionProposeRequest WalletConnectError: $err',
);
await core.pairing.sendError(
Expand Down
6 changes: 3 additions & 3 deletions lib/apis/utils/log_level.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum LogLevel {
Level toLevel() {
switch (this) {
case LogLevel.verbose:
return Level.verbose;
return Level.trace;
case LogLevel.debug:
return Level.debug;
case LogLevel.info:
Expand All @@ -22,9 +22,9 @@ enum LogLevel {
case LogLevel.error:
return Level.error;
case LogLevel.wtf:
return Level.wtf;
return Level.fatal;
default:
return Level.nothing;
return Level.off;
}
}
}
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
universal_io: ^2.0.4
stack_trace: ^1.10.0
web3dart: ^2.5.1
logger: ^1.4.0
logger: ^2.0.2+1
freezed_annotation: ^2.2.0

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion test/sign_api/utils/sign_client_test_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SignClientTestWrapper implements ISignEngine {
String relayUrl = WalletConnectConstants.DEFAULT_RELAY_URL,
required PairingMetadata metadata,
bool memoryStore = false,
Level logLevel = Level.nothing,
Level logLevel = Level.off,
IHttpClient httpClient = const HttpWrapper(),
}) async {
final client = SignClientTestWrapper(
Expand Down

0 comments on commit 3f289d1

Please sign in to comment.