Skip to content
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
10 changes: 4 additions & 6 deletions PCL.Core/IO/Net/Http/HttpSenderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ public async Task<HttpResponseMessage> SendAsync(
return await httpClient
.SendAsync(requestCopy, httpCompletionOption, token)
.ConfigureAwait(false);
}
catch(Exception ex)
}catch(Exception ex)
{
LogWrapper.Error(ex, "Request", $"Try attempt failed (id = {requestId})");
LogWrapper.Debug(ex, "Request", $"Try attempt failed (id = {requestId})");
throw;
}
},
cancellationToken,
false)
},cancellationToken
)
.ConfigureAwait(false);

if (enableLogging)
Expand Down
3 changes: 2 additions & 1 deletion PCL.Core/IO/Net/NetworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ public static AsyncPolicy GetRetryPolicy(int retry = 3, Func<int,TimeSpan>? retr
attempt => retryPolicy.Invoke(attempt),
onRetry: (exception, timeSpan, retryAttempt, context) =>
{
LogWrapper.Error(
LogWrapper.Debug(
exception,
"Network",
$"HTTP 请求失败,正在进行第 {retryAttempt} 次重试,等待 {timeSpan.TotalMilliseconds} 毫秒。"
);
});
Expand Down
2 changes: 2 additions & 0 deletions PCL.Core/Logging/LogWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static class LogWrapper
public static void Debug(string? module, string msg) => OnLog?.Invoke(LogLevel.Debug, msg, module);
public static void Debug(string msg) => Debug(null, msg);

public static void Debug(Exception ex, string module, string message) => Debug(module, $"{message}: {ex.ToString()}");

// Trace
public static void Trace(string? module, string msg) => OnLog?.Invoke(LogLevel.Trace, msg, module);
public static void Trace(string msg) => Trace(null, msg);
Expand Down
Loading