Skip to content

Commit

Permalink
🔧 (launchSettings.json): add new launch profile 'empty' for Migration…
Browse files Browse the repository at this point in the history
…Tools.ConsoleFull

♻️ (MigrationToolHost.cs): uncomment log filter for StartupService and add null check for configFile

Adding the 'empty' launch profile provides a new configuration option for running the project without any command line arguments, which can be useful for debugging or initial setup. Uncommenting the log filter for `MigrationTools.Host.StartupService` ensures that logs from this source are excluded, improving log readability. Adding a null check for `configFile` before adding it to the configuration builder prevents potential runtime errors if the file does not exist or the path is empty.
  • Loading branch information
MrHinsh committed Jul 25, 2024
1 parent 6b65ba1 commit 8bb90e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/MigrationTools.ConsoleFull/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"init2": {
"commandName": "Project",
"commandLineArgs": "init -c configuration2.json --options Fullv2"
},
"empty": {
"commandName": "Project"
}
}
}
5 changes: 4 additions & 1 deletion src/MigrationTools.Host/MigrationToolHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static IHostBuilder CreateDefaultBuilder(string[] args)
.WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate)
.WriteTo.Logger(lc => lc
.Filter.ByExcluding(Matching.FromSource("Microsoft"))
//.Filter.ByExcluding(Matching.FromSource("MigrationTools.Host.StartupService"))
.Filter.ByExcluding(Matching.FromSource("MigrationTools.Host.StartupService"))
.WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate))
.WriteTo.Logger(lc => lc
.Filter.ByExcluding(Matching.FromSource("Microsoft"))
Expand All @@ -67,7 +67,10 @@ public static IHostBuilder CreateDefaultBuilder(string[] args)
})
.ConfigureAppConfiguration(builder =>
{
if (!string.IsNullOrEmpty(configFile) && File.Exists(configFile))
{
builder.AddJsonFile(configFile);
}
});

hostBuilder.ConfigureServices((context, services) =>
Expand Down

0 comments on commit 8bb90e3

Please sign in to comment.