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

Allow custom http clients #1

Merged
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
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
"version": "1.0.0-preview2-003131"
}
}
11 changes: 8 additions & 3 deletions src/Serilog.Sinks.Http/LoggerSinkConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,24 @@ public static class LoggerSinkConfigurationExtensions
/// The minimum level for events passed through the sink. The default is
/// <see cref="LevelAlias.Minimum"/>.
/// </param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
/// <param name="httpClient">
/// A custom <see cref="IHttpClient"/> implementation.
/// </param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
public static LoggerConfiguration Http(
this LoggerSinkConfiguration sinkConfiguration,
string requestUri,
int? batchPostingLimit = null,
TimeSpan? period = null,
IFormatProvider formatProvider = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
IHttpClient httpClient = null)
{
if (sinkConfiguration == null)
throw new ArgumentNullException(nameof(sinkConfiguration));

var client = new HttpClientWrapper();
var client = httpClient ?? new HttpClientWrapper();

var sink = new HttpSink(
client,
requestUri,
Expand Down