Skip to content

Commit b91b8a2

Browse files
committed
better logging for notification
1 parent f0681af commit b91b8a2

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/Configuration/Notifications.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ private async void OnElapsed(object? source, ElapsedEventArgs e)
112112

113113
try
114114
{
115-
Logger.WriteLine($"Sending the request to {notification.Url}.");
116115
Response? response =
117116
await notification.SendAsync().ConfigureAwait(false);
118117

@@ -121,7 +120,7 @@ private async void OnElapsed(object? source, ElapsedEventArgs e)
121120
continue;
122121
}
123122

124-
Logger.WriteLine($"Response: {response.StatusCode}. Content: {response.Content}");
123+
Logger.WriteLine($"Response: {response.StatusCode}. URL: {response.Url}. Content: {response.Content}");
125124

126125
}
127126
catch (AggregateException aex)

src/Net/Request.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ await client.SendAsync(request).ConfigureAwait(false))
107107
return new Response(
108108
requestResponse.StatusCode,
109109
requestResponse.ReasonPhrase,
110-
resultContent);
110+
resultContent,
111+
uri.OriginalString);
111112
}
112113
}
113114
}
@@ -116,7 +117,8 @@ await client.SendAsync(request).ConfigureAwait(false))
116117
return new Response(
117118
System.Net.HttpStatusCode.InternalServerError,
118119
"Request could not be sent. Reason: The HTTP client service could not be initialized.",
119-
null); ;
120+
null,
121+
uri.OriginalString); ;
120122
}
121123
}
122124
catch (Exception ex)
@@ -125,7 +127,8 @@ await client.SendAsync(request).ConfigureAwait(false))
125127
return new Response(
126128
System.Net.HttpStatusCode.InternalServerError,
127129
$"Request could not be sent. Reason: {ex.Message}",
128-
null);
130+
null,
131+
uri.OriginalString);
129132
}
130133
}
131134
}

src/Net/Response.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ internal class Response
2222
/// </summary>
2323
internal string? Content { get; private set; }
2424

25+
/// <summary>
26+
/// Gets the URL for the response.
27+
/// </summary>
28+
internal string? Url { get; private set; }
29+
2530
/// <summary>
2631
/// Initializes a new instance of the <see cref="Response"/> class
2732
/// when provided with the status code, reason phrase and the
@@ -36,11 +41,12 @@ internal class Response
3641
/// <param name="content">
3742
/// The content from the request.
3843
/// </param>
39-
internal Response(HttpStatusCode statusCode, string? reasonPhrase, string? content)
44+
internal Response(HttpStatusCode statusCode, string? reasonPhrase, string? content, string? url)
4045
{
4146
StatusCode = statusCode;
4247
ReasonPhrase = reasonPhrase;
4348
Content = content;
49+
Url = url;
4450
}
4551
}
4652
}

0 commit comments

Comments
 (0)