-
Notifications
You must be signed in to change notification settings - Fork 19
Adjust overloads and parameter order to resolve potential ambiguous method call errors #59
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,42 +41,33 @@ public static LoggerConfiguration TCPSink( | |
this LoggerSinkConfiguration loggerConfiguration, | ||
IPAddress ipAddress, | ||
int port, | ||
int? writeTimeoutMs = null, | ||
int? disposeTimeoutMs = null, | ||
ITextFormatter? textFormatter = null, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) | ||
{ | ||
return TCPSink(loggerConfiguration, $"tcp://{ipAddress}:{port}", writeTimeoutMs, disposeTimeoutMs, textFormatter, restrictedToMinimumLevel); | ||
} | ||
|
||
public static LoggerConfiguration TCPSink( | ||
this LoggerSinkConfiguration loggerConfiguration, | ||
IPAddress ipAddress, | ||
int port, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, | ||
int? writeTimeoutMs = null, | ||
int? disposeTimeoutMs = null) | ||
{ | ||
return TCPSink(loggerConfiguration, ipAddress, port,null, null, null, restrictedToMinimumLevel); | ||
return TCPSink(loggerConfiguration, $"tcp://{ipAddress}:{port}", textFormatter, restrictedToMinimumLevel, writeTimeoutMs, disposeTimeoutMs); | ||
} | ||
|
||
public static LoggerConfiguration TCPSink( | ||
this LoggerSinkConfiguration loggerConfiguration, | ||
string host, | ||
int port, | ||
int? writeTimeoutMs = null, | ||
int? disposeTimeoutMs = null, | ||
ITextFormatter? textFormatter = null, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, | ||
int? writeTimeoutMs = null, | ||
int? disposeTimeoutMs = null) | ||
{ | ||
return TCPSink(loggerConfiguration, $"{host}:{port}", writeTimeoutMs, disposeTimeoutMs, textFormatter, restrictedToMinimumLevel); | ||
return TCPSink(loggerConfiguration, $"{host}:{port}", textFormatter, restrictedToMinimumLevel, writeTimeoutMs, disposeTimeoutMs); | ||
} | ||
|
||
public static LoggerConfiguration TCPSink( | ||
this LoggerSinkConfiguration loggerConfiguration, | ||
string uri, | ||
int? writeTimeoutMs = null, | ||
int? disposeTimeoutMs = null, | ||
ITextFormatter? textFormatter = null, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, | ||
int? writeTimeoutMs = null, | ||
int? disposeTimeoutMs = null) | ||
{ | ||
var socketWriter = new TcpSocketWriter( | ||
BuildUri(uri), | ||
|
@@ -86,14 +77,6 @@ public static LoggerConfiguration TCPSink( | |
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel); | ||
} | ||
|
||
public static LoggerConfiguration TCPSink( | ||
this LoggerSinkConfiguration loggerConfiguration, | ||
string uri, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) | ||
{ | ||
return TCPSink(loggerConfiguration, uri, null, null, null, restrictedToMinimumLevel); | ||
} | ||
|
||
Comment on lines
-89
to
-96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This overload was added in #51 and included in 3.0.0-alpha.1. Code like I think this one can be safely removed since it is only in an alpha release and the same functionality can be achieved using the overload above with args like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I added this because of #51 (comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, but I was thinking that rather than add that overload, we could address the concern in that comment by putting the new optional parameters public static LoggerConfiguration TCPSink(
this LoggerSinkConfiguration loggerConfiguration,
string uri,
ITextFormatter? textFormatter = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
int? writeTimeoutMs = null,
int? disposeTimeoutMs = null) That way, existing code that was calling that existing method like Does that make sense and seem OK to you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, works for me. |
||
private static IPAddress ResolveAddress(string uri) | ||
{ | ||
// Check if it is IP address | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overload
was added in #51 included in 3.0.0-alpha.1 but I think can be safely removed. It can cause ambiguous call errors with code like
TCPSink(IPAddress.Parse("127.0.0.1"), 1234)
because the overload above could also match.I think this is OK to remove because the overload above can cover the same functionality/parameters with calls like this:
TCPSink(IPAddress.Parse("127.0.0.1"), 1234, restrictedToMinimumLevel: logLevel)