From e698554a6cd6fd066963a3a7bfaa99ac6eb8ac37 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 24 Dec 2021 16:24:18 +0000 Subject: [PATCH] --- server/AyaNova/Program.cs | 2 +- server/AyaNova/Startup.cs | 71 +++++++++++++++------------------------ 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/server/AyaNova/Program.cs b/server/AyaNova/Program.cs index 1c79d19b..218f5990 100644 --- a/server/AyaNova/Program.cs +++ b/server/AyaNova/Program.cs @@ -308,7 +308,7 @@ namespace AyaNova public static IHostBuilder BuildHost(string[] args, NLog.Logger logger) { - logger.Debug("Building host"); + logger.LogTrace("Building host"); var configuration = new ConfigurationBuilder().AddCommandLine(args).Build(); return Host.CreateDefaultBuilder(args) diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 4ec479a9..5bff37bc 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -51,12 +51,12 @@ namespace AyaNova // public void ConfigureServices(IServiceCollection services) { - _newLog.LogDebug("Initializing services..."); + _newLog.LogTrace("Initializing services..."); - _newLog.LogDebug("Health"); + _newLog.LogTrace("Health"); services.AddHealthChecks().AddDbContextCheck(); ; - _newLog.LogDebug("Profiler"); + _newLog.LogTrace("Profiler"); //https://dotnetthoughts.net/using-miniprofiler-in-aspnetcore-webapi/ services.AddMemoryCache(); services.AddMiniProfiler(options => @@ -75,15 +75,15 @@ namespace AyaNova //Server state service for shutting people out of api - _newLog.LogDebug("ServerState service"); + _newLog.LogTrace("ServerState service"); services.AddSingleton(new AyaNova.Api.ControllerHelpers.ApiServerState()); - _newLog.LogDebug("Mail service"); + _newLog.LogTrace("Mail service"); services.AddSingleton(); //Init controllers - _newLog.LogDebug("Controllers"); + _newLog.LogTrace("Controllers"); var MvcBuilder = services.AddControllers(config => { // config.Filters.Add(new AyaNova.Api.ControllerHelpers.ApiCustomExceptionFilter(AyaNova.Util.ApplicationLogging.LoggerFactory)); @@ -100,7 +100,7 @@ namespace AyaNova options.SuppressModelStateInvalidFilter = true; }); - _newLog.LogDebug("JSON"); + _newLog.LogTrace("JSON"); MvcBuilder.AddNewtonsoftJson(options => { @@ -112,12 +112,12 @@ namespace AyaNova //HTTP CLIENT FACTORY USED BY LICENSE.CS //https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1 - _newLog.LogDebug("HTTPClientFactory"); + _newLog.LogTrace("HTTPClientFactory"); services.AddHttpClient(); - + //TODO: ENsure report files here @@ -157,7 +157,7 @@ namespace AyaNova #endif - _newLog.LogDebug("EF Core"); + _newLog.LogTrace("EF Core"); //change to resolve error: @@ -180,7 +180,7 @@ namespace AyaNova // Add service and create Policy with options - _newLog.LogDebug("CORS"); + _newLog.LogTrace("CORS"); services.AddCors(options => { options.AddPolicy("CorsPolicy", @@ -271,7 +271,7 @@ namespace AyaNova ServerBootConfig.AYANOVA_JWT_SECRET = secretKey; var signingKey = new SymmetricSecurityKey(System.Text.Encoding.ASCII.GetBytes(ServerBootConfig.AYANOVA_JWT_SECRET)); - _newLog.LogDebug("Authorization"); + _newLog.LogTrace("Authorization"); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; @@ -305,7 +305,7 @@ namespace AyaNova - _newLog.LogDebug("Generator"); + _newLog.LogTrace("Generator"); services.AddSingleton(); } @@ -319,7 +319,7 @@ namespace AyaNova AyContext dbContext, IApiVersionDescriptionProvider provider, AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, IServiceProvider serviceProvider) { - _newLog.LogDebug("Configuring request pipeline..."); + _newLog.LogTrace("Configuring request pipeline..."); //this *may* be useful in the event of an issue so uncomment if necessary but errors during dev are handled equally by the logging, I think // if (env.IsDevelopment()) @@ -346,7 +346,7 @@ namespace AyaNova #region STATIC FILES - _newLog.LogDebug("Static files"); + _newLog.LogTrace("Static files"); app.UseDefaultFiles(); app.UseStaticFiles(); //Might need the following if the page doesn't update in the client properly @@ -364,19 +364,19 @@ namespace AyaNova // }); #endregion - _newLog.LogDebug("Routing pipeline"); + _newLog.LogTrace("Routing pipeline"); app.UseRouting();//this wasn't here for 2.2 but added for 3.0, needs to come before the stuff after - _newLog.LogDebug("CORS pipeline"); + _newLog.LogTrace("CORS pipeline"); app.UseCors("CorsPolicy"); #region AUTH / ROLES CUSTOM MIDDLEWARE - _newLog.LogDebug("Authentication pipeline"); + _newLog.LogTrace("Authentication pipeline"); //Use authentication middleware app.UseAuthentication(); - _newLog.LogDebug("Authorization pipeline"); + _newLog.LogTrace("Authorization pipeline"); app.UseAuthorization(); @@ -496,12 +496,12 @@ namespace AyaNova #endregion - _newLog.LogDebug("Profiler"); + _newLog.LogTrace("Profiler"); app.UseMiniProfiler(); - _newLog.LogDebug("Endpoints pipeline"); + _newLog.LogTrace("Endpoints pipeline"); app.UseEndpoints(endpoints => { endpoints.MapHealthChecks("/health"); @@ -510,7 +510,7 @@ namespace AyaNova #region SWAGGER - _newLog.LogDebug("API explorer pipeline"); + _newLog.LogTrace("API explorer pipeline"); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); app.UseSwaggerUI( @@ -532,20 +532,6 @@ namespace AyaNova #endregion swagger - // ****************************************************************** - // ******************** TESTING WIPE DB ***************************** - // - //Set this to true to wipe the db and reinstall a trial license and re-seed the data - //DEPRECATED, now use boot setting AYANOVA_SERVER_TEST_MODE - // var TESTING_REFRESH_DB = true;//####################################################################################### - - // #if (DEBUG) - - // //TESTING - // if (TESTING_REFRESH_DB) - // ServerBootConfig.AYANOVA_PERMANENTLY_ERASE_DATABASE = TESTING_REFRESH_DB; - // //TESTING - // #endif if (ServerBootConfig.AYANOVA_PERMANENTLY_ERASE_DATABASE || ServerBootConfig.AYANOVA_SERVER_TEST_MODE) @@ -569,7 +555,7 @@ namespace AyaNova _newLog.LogInformation("Database server version - {0}", dbServerVersionInfo); //db server extended parameters - _newLog.LogDebug($"Database server runtime parameters{Environment.NewLine}{string.Join(Environment.NewLine, dbServerRunTimeParameters)}"); + _newLog.LogTrace($"Database server runtime parameters{Environment.NewLine}{string.Join(Environment.NewLine, dbServerRunTimeParameters)}"); ServerBootConfig.DBSERVER_DIAGNOSTIC_INFO.Add("DB SERVER", dbServerVersionInfo); foreach (var p in dbServerRunTimeParameters) @@ -584,13 +570,13 @@ namespace AyaNova //Check schema - _newLog.LogDebug("DB schema check"); + _newLog.LogTrace("DB schema check"); AySchema.CheckAndUpdateAsync(dbContext, _newLog).Wait(); //Check database integrity - _newLog.LogDebug("DB integrity check"); + _newLog.LogTrace("DB integrity check"); DbUtil.CheckFingerPrintAsync(AySchema.EXPECTED_COLUMN_COUNT, AySchema.EXPECTED_INDEX_COUNT, AySchema.EXPECTED_CHECK_CONSTRAINTS, @@ -603,10 +589,10 @@ namespace AyaNova AyaNova.Core.License.InitializeAsync(apiServerState, dbContext, _newLog).Wait(); //Set static global biz settings - _newLog.LogDebug("Global settings"); + _newLog.LogTrace("Global settings"); ServerGlobalBizSettings.Initialize(null, dbContext); - _newLog.LogDebug("Ops settings"); + _newLog.LogTrace("Ops settings"); ServerGlobalOpsSettingsCache.Initialize(dbContext); //Ensure translations are present, not missing any keys and that there is a server default translation that exists @@ -623,7 +609,6 @@ namespace AyaNova #else AyaNova.Core.License.FetchKeyAsync(apiServerState, dbContext, _newLog, true).Wait(); #endif - //NOTE: For unit testing make sure the time zone is same as tester to ensure list filter by date tests will work because server is on same page as user in terms of time var seed = new Util.Seeder(); seed.SeedDatabaseAsync(Seeder.Level.StringToSeedLevel(ServerBootConfig.AYANOVA_SERVER_TEST_MODE_SEEDLEVEL), ServerBootConfig.AYANOVA_SERVER_TEST_MODE_TZ_OFFSET).Wait(); } @@ -665,7 +650,7 @@ namespace AyaNova ServerGlobalOpsSettingsCache.BOOTING = false; //Open up the server for visitors - _newLog.LogDebug("Setting server state open"); + _newLog.LogTrace("Setting server state open"); apiServerState.SetOpen(); //final startup log