Skip to content

Commit b258c55

Browse files
authored
Merge pull request #320 from 0xsequence/Feature/log-wrapper
added custom log class SequenceLog
2 parents e868dc4 + 167e669 commit b258c55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+201
-140
lines changed

Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/OpenIdAuthenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public void PlatformSpecificSetup()
282282
catch (Exception ex)
283283
{
284284
string message = $"Failed to register URL scheme '{_urlScheme}': {ex.Message}" + "\nSocial sign in is not currently supported on IL2CPP";
285-
Debug.LogWarning(message);
285+
SequenceLog.Warning(message);
286286
throw new Exception(message);
287287
}
288288
#endif
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"name": "AppleAuth"
2+
"name": "AppleAuth",
3+
"references":[ "GUID:b4f9c0f8f363f439b9e337f79050f189" ]
34
}

Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/SignInWithApple/AppleAuth/AppleAuthManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using AppleAuth.Enums;
66
using AppleAuth.Interfaces;
77
using System;
8+
using Sequence.Utils;
89

910
namespace AppleAuth
1011
{
@@ -16,7 +17,7 @@ static AppleAuthManager()
1617
#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
1718
PInvoke.AppleAuth_LogMessage(versionMessage);
1819
#else
19-
UnityEngine.Debug.Log(versionMessage);
20+
SequenceLog.Info(versionMessage);
2021
#endif
2122
}
2223

Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/WebAuthSuccessPoller.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ private async Task<bool> SendGetSuccessRequest()
7373
}
7474
catch (HttpRequestException e)
7575
{
76-
Debug.LogError("HTTP Request failed: " + e.Message);
76+
SequenceLog.Error("HTTP Request failed: " + e.Message);
7777
}
7878
catch (FormatException e)
7979
{
80-
Debug.LogError("Invalid URL format: " + e.Message + "\nCurl-equivalent request: " + curlRequest);
80+
SequenceLog.Error("Invalid URL format: " + e.Message + "\nCurl-equivalent request: " + curlRequest);
8181
}
8282
catch (FileLoadException e)
8383
{
84-
Debug.LogError("File load exception: " + e.Message + "\nCurl-equivalent request: " + curlRequest);
84+
SequenceLog.Error("File load exception: " + e.Message + "\nCurl-equivalent request: " + curlRequest);
8585
}
8686
catch (Exception e) {
87-
Debug.LogError("An unexpected error occurred: " + e.Message + "\nCurl-equivalent request: " + curlRequest);
87+
SequenceLog.Error("An unexpected error occurred: " + e.Message + "\nCurl-equivalent request: " + curlRequest);
8888
}
8989

9090
return false;

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/DataTypes/ParameterTypes/SendERC721.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using Newtonsoft.Json;
3+
using Sequence.Utils;
34
using UnityEngine;
45
using UnityEngine.Scripting;
56

@@ -25,7 +26,7 @@ public SendERC721(string tokenAddress, string to, string tokenId, bool safe = tr
2526
this.safe = safe;
2627
if (!safe && data != null)
2728
{
28-
Debug.LogError($"Error creating {GetType().Name}: {nameof(data)} can only be set when {nameof(safe)} is true.\nUsing null data.");
29+
SequenceLog.Error($"Error creating {GetType().Name}: {nameof(data)} can only be set when {nameof(safe)} is true.\nUsing null data.");
2930
data = null;
3031
}
3132
this.data = data;

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/DataTypes/ParameterTypes/TransactionsValidator.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using Sequence.ABI;
33
using Sequence.Contracts;
4+
using Sequence.Utils;
45
using UnityEngine;
56

67
namespace Sequence.EmbeddedWallet
@@ -23,7 +24,7 @@ public static void Validate(Transaction[] transactions)
2324
if (!ABIRegex.MatchesFunctionABI(delayedEncode.data.abi))
2425
{
2526
string message = $"Given {nameof(DelayedEncode)} transaction with function abi {delayedEncode.data.abi} that does not match the required regex {ABIRegex.FunctionABIRegex} - for example: \"mint(uint256,uint256)\"";
26-
Debug.LogWarning(message + "\nAttempting to recover and parse anyways");
27+
SequenceLog.Warning(message + "\nAttempting to recover and parse anyways");
2728
delayedEncode.data.abi = EventParser.ParseEventDef(delayedEncode.data.abi).ToString();
2829
if (!ABIRegex.MatchesFunctionABI(delayedEncode.data.abi))
2930
{
@@ -43,7 +44,7 @@ public static void Validate(Transaction[] transactions)
4344
if (!ABIRegex.MatchesFunctionABI(contractCall.data.abi))
4445
{
4546
string message = $"Given {nameof(SequenceContractCall)} transaction with function abi {contractCall.data.abi} that does not match the required regex {ABIRegex.FunctionABIRegex} - for example: \"mint(uint256,uint256)\"";
46-
Debug.LogWarning(message + "\nAttempting to recover and parse anyways");
47+
SequenceLog.Warning(message + "\nAttempting to recover and parse anyways");
4748
contractCall.data.abi = EventParser.ParseEventDef(contractCall.data.abi).ToString();
4849
if (!ABIRegex.MatchesFunctionABI(contractCall.data.abi))
4950
{

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/DataTypes/ReturnTypes/SuccessfulTransactionReturn.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Newtonsoft.Json;
44
using System.Collections.Generic;
55
using System;
6+
using Sequence.Utils;
67
using UnityEngine.Scripting;
78

89
namespace Sequence.EmbeddedWallet
@@ -65,7 +66,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
6566
}
6667
catch (Exception ex)
6768
{
68-
UnityEngine.Debug.LogError($"Failed to load JSON: {ex.Message}");
69+
SequenceLog.Error($"Failed to load JSON: {ex.Message}");
6970
throw;
7071
}
7172

@@ -91,7 +92,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
9192
}
9293
catch (Exception ex)
9394
{
94-
UnityEngine.Debug.LogError($"Error during JSON conversion: {ex.Message}");
95+
SequenceLog.Error($"Error during JSON conversion: {ex.Message}");
9596
throw;
9697
}
9798

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/EOAWalletLinker.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4+
using Sequence.Utils;
45
using UnityEngine;
56
using UnityEngine.Scripting;
67

@@ -43,7 +44,7 @@ public async Task<LinkedWalletData[]> GetLinkedWallets()
4344
}
4445
catch (Exception e)
4546
{
46-
Debug.LogException(e);
47+
SequenceLog.Exception(e);
4748
return Array.Empty<LinkedWalletData>();
4849
}
4950
}
@@ -71,7 +72,7 @@ await client.SendRequest<LinkedWalletsRequestData, LinkedWalletsResponseData>(
7172
}
7273
catch (Exception e)
7374
{
74-
Debug.LogException(e);
75+
SequenceLog.Exception(e);
7576
return false;
7677
}
7778
}
@@ -98,7 +99,7 @@ await client.SendRequest<NonceRequestData, NonceResponseData>("",
9899
}
99100
catch (System.Exception e)
100101
{
101-
Debug.LogError($"Failed to generate EOA Wallet Link: {e}");
102+
SequenceLog.Error($"Failed to generate EOA Wallet Link: {e}");
102103
return null;
103104
}
104105
}

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/EOAWalletToSequenceWalletAdapter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Sequence.Provider;
99
using Newtonsoft.Json;
1010
using Newtonsoft.Json.Linq;
11+
using Sequence.Utils;
1112
using UnityEngine;
1213
namespace Sequence.EmbeddedWallet
1314
{
@@ -171,7 +172,7 @@ public async Task<TransactionReturn> SendTransaction(Chain network, Transaction[
171172
}
172173
catch (Exception e)
173174
{
174-
Debug.LogError("Error while waiting for receipt: " + e.Message);
175+
SequenceLog.Error("Error while waiting for receipt: " + e.Message);
175176
string receiptExString = e.Message;
176177
var failedReturn = new FailedTransactionReturn(e.Message, null, null);
177178
failedTransactionReturns.Add(failedReturn);

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/HttpClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public async Task<T2> SendRequest<T, T2>(string path, T args, [CanBeNull] Dictio
137137
UnityWebRequest request = newRequest.Item1;
138138
string curlRequest = newRequest.Item2;
139139
string url = newRequest.Item3;
140-
Debug.Log(curlRequest);
140+
141+
SequenceLog.Info($">> {curlRequest}");
141142

142143
try
143144
{
@@ -174,6 +175,7 @@ public async Task<T2> SendRequest<T, T2>(string path, T args, [CanBeNull] Dictio
174175
}
175176
try
176177
{
178+
SequenceLog.Info($"<< {responseJson} (from {url})");
177179
T2 result = JsonConvert.DeserializeObject<T2>(responseJson);
178180
return result;
179181
}
@@ -254,7 +256,7 @@ public async Task<TimeSpan> GetTimeShift()
254256
}
255257
catch (Exception e)
256258
{
257-
Debug.LogError("Error getting time shift: " + e.Message);
259+
SequenceLog.Error("Error getting time shift: " + e.Message);
258260
return TimeSpan.Zero;
259261
}
260262
finally

0 commit comments

Comments
 (0)