-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(logging): fix null object reference without logging configured (#70)
- Loading branch information
1 parent
f2d6a70
commit 54b06c1
Showing
9 changed files
with
57 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using APIMatic.Core.Types.Sdk; | ||
|
||
namespace APIMatic.Core.Utilities.Logger | ||
{ | ||
internal interface ISdkLogger | ||
{ | ||
/// <summary> | ||
/// Logs the details of a request. | ||
/// </summary> | ||
/// <param name="request">The request to be logged.</param> | ||
void LogRequest(CoreRequest request); | ||
|
||
/// <summary> | ||
/// Logs the details of a response. | ||
/// </summary> | ||
/// <param name="response">The response to be logged.</param> | ||
void LogResponse(CoreResponse response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using APIMatic.Core.Types.Sdk; | ||
|
||
namespace APIMatic.Core.Utilities.Logger | ||
{ | ||
internal class NullSdkLogger : ISdkLogger | ||
{ | ||
public void LogRequest(CoreRequest request) | ||
{ | ||
// Method intentionally left empty. | ||
} | ||
|
||
public void LogResponse(CoreResponse response) | ||
{ | ||
// Method intentionally left empty. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using APIMatic.Core.Utilities.Logger.Configuration; | ||
|
||
namespace APIMatic.Core.Utilities.Logger | ||
{ | ||
internal static class SdkLoggerFactory | ||
{ | ||
public static ISdkLogger Create(SdkLoggingConfiguration sdkLoggingConfiguration) => | ||
sdkLoggingConfiguration == null | ||
? (ISdkLogger)new NullSdkLogger() | ||
: new SdkLogger(sdkLoggingConfiguration); | ||
} | ||
} |