From 76fca6c2ead6615afc0d0486728dec2d39f28909 Mon Sep 17 00:00:00 2001 From: bounav Date: Wed, 11 Dec 2024 12:03:34 +0000 Subject: [PATCH] Replaced log4net dependency with Microsoft.Extensions.Logging.Abstractions - This will allow anyone consuming this the ebay oauth client to plug-in the logging framework of they might favour --- .../ApiClient/Auth/OAuth2/CredentialUtil.cs | 11 +++++------ .../eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs | 18 ++++++++++++------ .../ebay-oauth-csharp-client.csproj | 2 +- .../ebay-oauth-csharp-client.nuspec | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/CredentialUtil.cs b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/CredentialUtil.cs index f268e4c..63e8de5 100644 --- a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/CredentialUtil.cs +++ b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/CredentialUtil.cs @@ -21,14 +21,13 @@ using System.IO; using eBay.ApiClient.Auth.OAuth2.Model; using YamlDotNet.RepresentationModel; -using log4net; using System.Collections.Concurrent; +using Microsoft.Extensions.Logging; namespace eBay.ApiClient.Auth.OAuth2 { public static class CredentialUtil { - private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); static readonly ConcurrentDictionary envCredentials = new ConcurrentDictionary(); public class Credentials { @@ -56,17 +55,17 @@ public String Get(CredentialType credentialType) /* * Loading StreamReader */ - public static void Load(String yamlFile) + public static void Load(String yamlFile, ILogger logger) { //Stream the input file StreamReader streamReader = new StreamReader(yamlFile); - Load(streamReader); + Load(streamReader, logger); } /* * Loading YAML file */ - public static void Load(StreamReader streamReader) + public static void Load(StreamReader streamReader, ILogger logger) { //Load the stream @@ -94,7 +93,7 @@ public static void Load(StreamReader streamReader) } } - log.Info("Loaded configuration for eBay oAuth Token"); + logger.LogInformation("Loaded configuration for eBay oAuth Token"); } diff --git a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs index 32b97c0..14b027b 100644 --- a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs +++ b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs @@ -23,13 +23,19 @@ using System.Net; using Newtonsoft.Json; using System.Text; -using log4net; +using Microsoft.Extensions.Logging; namespace eBay.ApiClient.Auth.OAuth2 { public class OAuth2Api { - private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private readonly ILogger logger; + + public OAuth2Api(ILogger logger) + { + this.logger = logger; + } + private static AppTokenCache appTokenCache = new AppTokenCache(); private class AppTokenCache @@ -88,7 +94,7 @@ public OAuthResponse GetApplicationToken(OAuthEnvironment environment, IList + - diff --git a/ebay-oauth-csharp-client/ebay-oauth-csharp-client.nuspec b/ebay-oauth-csharp-client/ebay-oauth-csharp-client.nuspec index 6796e27..13dec93 100644 --- a/ebay-oauth-csharp-client/ebay-oauth-csharp-client.nuspec +++ b/ebay-oauth-csharp-client/ebay-oauth-csharp-client.nuspec @@ -19,7 +19,7 @@ - +