@@ -32,23 +32,24 @@ public class LlmGatewayOptions
3232
3333public static class ServicesExtension
3434{
35+ private static ILogger ? GetLogger ( IServiceCollection services )
36+ {
37+ using var serviceProvider = services . BuildServiceProvider ( ) ;
38+ var loggerFactory = serviceProvider . GetService < ILoggerFactory > ( ) ;
39+ return loggerFactory ? . CreateLogger ( typeof ( ServicesExtension ) ) ;
40+ }
41+
3542 public static void AddElasticDocsApiUsecases ( this IServiceCollection services , string ? appEnvironment )
3643 {
3744 if ( AppEnvironmentExtensions . TryParse ( appEnvironment , out var parsedEnvironment , true ) )
3845 {
39- AddElasticDocsApiUsecases (
40- services ,
41- parsedEnvironment
42- ) ;
46+ AddElasticDocsApiUsecases ( services , parsedEnvironment ) ;
4347 }
4448 else
4549 {
46- var logger = services . BuildServiceProvider ( ) . GetRequiredService < ILogger > ( ) ;
47- logger . LogWarning ( "Unable to parse environment {Environment} into AppEnvironment. Using default AppEnvironment.Dev" , appEnvironment ) ;
48- AddElasticDocsApiUsecases (
49- services ,
50- AppEnvironment . Dev
51- ) ;
50+ var logger = GetLogger ( services ) ;
51+ logger ? . LogWarning ( "Unable to parse environment {AppEnvironment} into AppEnvironment. Using default AppEnvironment.Dev" , appEnvironment ) ;
52+ AddElasticDocsApiUsecases ( services , AppEnvironment . Dev ) ;
5253 }
5354 }
5455
@@ -67,12 +68,15 @@ private static void AddElasticDocsApiUsecases(this IServiceCollection services,
6768 // https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html
6869 private static void AddParameterProvider ( IServiceCollection services , AppEnvironment appEnvironment )
6970 {
71+ var logger = GetLogger ( services ) ;
72+
7073 switch ( appEnvironment )
7174 {
7275 case AppEnvironment . Prod :
7376 case AppEnvironment . Staging :
7477 case AppEnvironment . Edge :
7578 {
79+ logger ? . LogInformation ( "Configuring LambdaExtensionParameterProvider for environment {AppEnvironment}" , appEnvironment ) ;
7680 _ = services . AddHttpClient ( LambdaExtensionParameterProvider . HttpClientName , client =>
7781 {
7882 client . BaseAddress = new Uri ( "http://localhost:2773" ) ;
@@ -83,6 +87,7 @@ private static void AddParameterProvider(IServiceCollection services, AppEnviron
8387 }
8488 case AppEnvironment . Dev :
8589 {
90+ logger ? . LogInformation ( "Configuring LocalParameterProvider for environment {AppEnvironment}" , appEnvironment ) ;
8691 _ = services . AddSingleton < IParameterProvider , LocalParameterProvider > ( ) ;
8792 break ;
8893 }
@@ -96,6 +101,9 @@ private static void AddParameterProvider(IServiceCollection services, AppEnviron
96101
97102 private static void AddAskAiUsecase ( IServiceCollection services , AppEnvironment appEnvironment )
98103 {
104+ var logger = GetLogger ( services ) ;
105+ logger ? . LogInformation ( "Configuring AskAi use case for environment {AppEnvironment}" , appEnvironment ) ;
106+
99107 _ = services . Configure < LlmGatewayOptions > ( options =>
100108 {
101109 var serviceProvider = services . BuildServiceProvider ( ) ;
0 commit comments