2121using System . Net . Http . Headers ;
2222using System . Text . Json ;
2323using Org . OpenAPITools . Client ;
24+ using Org . OpenAPITools . Logging ;
2425using System . Diagnostics . CodeAnalysis ;
2526
2627namespace Org . OpenAPITools . Api
@@ -105,11 +106,6 @@ public sealed partial class DefaultApi : IDefaultApi
105106 {
106107 private JsonSerializerOptions _jsonSerializerOptions ;
107108
108- /// <summary>
109- /// The logger factory
110- /// </summary>
111- public ILoggerFactory LoggerFactory { get ; }
112-
113109 /// <summary>
114110 /// The logger
115111 /// </summary>
@@ -129,11 +125,10 @@ public sealed partial class DefaultApi : IDefaultApi
129125 /// Initializes a new instance of the <see cref="DefaultApi"/> class.
130126 /// </summary>
131127 /// <returns></returns>
132- public DefaultApi ( ILogger < DefaultApi > logger , ILoggerFactory loggerFactory , HttpClient httpClient , JsonSerializerOptionsProvider jsonSerializerOptionsProvider , DefaultApiEvents defaultApiEvents )
128+ public DefaultApi ( ILogger < DefaultApi > logger , HttpClient httpClient , JsonSerializerOptionsProvider jsonSerializerOptionsProvider , DefaultApiEvents defaultApiEvents )
133129 {
134130 _jsonSerializerOptions = jsonSerializerOptionsProvider . Options ;
135- LoggerFactory = loggerFactory ;
136- Logger = LoggerFactory . CreateLogger < DefaultApi > ( ) ;
131+ Logger = logger ;
137132 HttpClient = httpClient ;
138133 Events = defaultApiEvents ;
139134 }
@@ -161,7 +156,7 @@ private void AfterListDefaultImplementation(IListApiResponse apiResponseLocalVar
161156 bool suppressDefaultLog = false ;
162157 AfterList ( ref suppressDefaultLog , apiResponseLocalVar , personId ) ;
163158 if ( ! suppressDefaultLog )
164- Logger . LogInformation ( "{0,-9} | {1} | {2}" , ( apiResponseLocalVar . DownloadedAt - apiResponseLocalVar . RequestedAt ) . TotalSeconds , apiResponseLocalVar . StatusCode , apiResponseLocalVar . Path ) ;
159+ Logger . LogInformation ( RestLogEvents . ApiRequestCompleted , "{0,-9} | {1} | {2}" , ( apiResponseLocalVar . DownloadedAt - apiResponseLocalVar . RequestedAt ) . TotalSeconds , apiResponseLocalVar . StatusCode , apiResponseLocalVar . Path ) ;
165160 }
166161
167162 /// <summary>
@@ -184,7 +179,7 @@ private void OnErrorListDefaultImplementation(Exception exceptionLocalVar, strin
184179 bool suppressDefaultLogLocalVar = false ;
185180 OnErrorList ( ref suppressDefaultLogLocalVar , exceptionLocalVar , pathFormatLocalVar , pathLocalVar , personId ) ;
186181 if ( ! suppressDefaultLogLocalVar )
187- Logger . LogError ( exceptionLocalVar , "An error occurred while sending the request to the server." ) ;
182+ Logger . LogError ( RestLogEvents . ApiRequestFailed , exceptionLocalVar , "An error occurred while sending the request to the server." ) ;
188183 }
189184
190185 /// <summary>
@@ -259,13 +254,12 @@ public async Task<IListApiResponse> ListAsync(string personId, System.Threading.
259254
260255 using ( HttpResponseMessage httpResponseMessageLocalVar = await HttpClient . SendAsync ( httpRequestMessageLocalVar , cancellationToken ) . ConfigureAwait ( false ) )
261256 {
262- ILogger < ListApiResponse > apiResponseLoggerLocalVar = LoggerFactory . CreateLogger < ListApiResponse > ( ) ;
263257 ListApiResponse apiResponseLocalVar ;
264258
265259 switch ( ( int ) httpResponseMessageLocalVar . StatusCode ) {
266260 default : {
267261 string responseContentLocalVar = await httpResponseMessageLocalVar . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
268- apiResponseLocalVar = new ( apiResponseLoggerLocalVar , httpRequestMessageLocalVar , httpResponseMessageLocalVar , responseContentLocalVar , "/person/display/{personId}" , requestedAtLocalVar , _jsonSerializerOptions ) ;
262+ apiResponseLocalVar = new ( Logger , httpRequestMessageLocalVar , httpResponseMessageLocalVar , responseContentLocalVar , "/person/display/{personId}" , requestedAtLocalVar , _jsonSerializerOptions ) ;
269263
270264 break ;
271265 }
@@ -295,7 +289,7 @@ public partial class ListApiResponse : Org.OpenAPITools.Client.ApiResponse, ILis
295289 /// <summary>
296290 /// The logger
297291 /// </summary>
298- public ILogger < ListApiResponse > Logger { get ; }
292+ public ILogger < DefaultApi > Logger { get ; }
299293
300294 /// <summary>
301295 /// The <see cref="ListApiResponse"/>
@@ -307,7 +301,7 @@ public partial class ListApiResponse : Org.OpenAPITools.Client.ApiResponse, ILis
307301 /// <param name="path"></param>
308302 /// <param name="requestedAt"></param>
309303 /// <param name="jsonSerializerOptions"></param>
310- public ListApiResponse ( ILogger < ListApiResponse > logger , System . Net . Http . HttpRequestMessage httpRequestMessage , System . Net . Http . HttpResponseMessage httpResponseMessage , string rawContent , string path , DateTime requestedAt , System . Text . Json . JsonSerializerOptions jsonSerializerOptions ) : base ( httpRequestMessage , httpResponseMessage , rawContent , path , requestedAt , jsonSerializerOptions )
304+ public ListApiResponse ( ILogger < DefaultApi > logger , System . Net . Http . HttpRequestMessage httpRequestMessage , System . Net . Http . HttpResponseMessage httpResponseMessage , string rawContent , string path , DateTime requestedAt , System . Text . Json . JsonSerializerOptions jsonSerializerOptions ) : base ( httpRequestMessage , httpResponseMessage , rawContent , path , requestedAt , jsonSerializerOptions )
311305 {
312306 Logger = logger ;
313307 OnCreated ( httpRequestMessage , httpResponseMessage ) ;
@@ -323,7 +317,7 @@ public ListApiResponse(ILogger<ListApiResponse> logger, System.Net.Http.HttpRequ
323317 /// <param name="path"></param>
324318 /// <param name="requestedAt"></param>
325319 /// <param name="jsonSerializerOptions"></param>
326- public ListApiResponse ( ILogger < ListApiResponse > logger , System . Net . Http . HttpRequestMessage httpRequestMessage , System . Net . Http . HttpResponseMessage httpResponseMessage , System . IO . Stream contentStream , string path , DateTime requestedAt , System . Text . Json . JsonSerializerOptions jsonSerializerOptions ) : base ( httpRequestMessage , httpResponseMessage , contentStream , path , requestedAt , jsonSerializerOptions )
320+ public ListApiResponse ( ILogger < DefaultApi > logger , System . Net . Http . HttpRequestMessage httpRequestMessage , System . Net . Http . HttpResponseMessage httpResponseMessage , System . IO . Stream contentStream , string path , DateTime requestedAt , System . Text . Json . JsonSerializerOptions jsonSerializerOptions ) : base ( httpRequestMessage , httpResponseMessage , contentStream , path , requestedAt , jsonSerializerOptions )
327321 {
328322 Logger = logger ;
329323 OnCreated ( httpRequestMessage , httpResponseMessage ) ;
@@ -374,7 +368,7 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht
374368 bool suppressDefaultLog = false ;
375369 OnDeserializationError ( ref suppressDefaultLog , exception , httpStatusCode ) ;
376370 if ( ! suppressDefaultLog )
377- Logger . LogError ( exception , "An error occurred while deserializing the {code} response." , httpStatusCode ) ;
371+ Logger . LogError ( RestLogEvents . ApiDeserializationFailed , exception , "An error occurred while deserializing the {code} response." , httpStatusCode ) ;
378372 }
379373
380374 partial void OnDeserializationError ( ref bool suppressDefaultLog , Exception exception , HttpStatusCode httpStatusCode ) ;
0 commit comments