Skip to content

Commit

Permalink
Merge pull request #5 from Xorcist77/4-app-crashes-when-logfile-path-…
Browse files Browse the repository at this point in the history
…is-not-p

4 App Crashes when Logfile-Path is not provided
  • Loading branch information
Xorcist77 authored Jul 6, 2024
2 parents ca67d71 + dc3a603 commit 0d5b67e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<appSettings>
<add key="Polling-Rate" value="5" />
<add key="Display-Info" value="True" />
<add key="Logfile-Path" value ="./logs"/>
<add key="Logfile-Path" value =".\logs"/>
</appSettings>
</configuration>
13 changes: 6 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.CommandLine.Help;
using System.CommandLine.Parsing;
using System.Configuration;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Linq;
using System.Management;
Expand Down Expand Up @@ -185,12 +186,10 @@ static async Task<Int32> Main(String[] args) {
parseArgument: result => {
String lf = null;
String err = "Logfile-Path must be a valid storage location";
if (!result.Tokens.Any()) {
try {
lf = ConfigurationManager.AppSettings["Logfile-Path"];
}
catch {
lf = Environment.CurrentDirectory;
if (!result.Tokens.Any()) {
lf = ConfigurationManager.AppSettings["Logfile-Path"];
if (lf == null) {
lf = Path.Combine(Environment.CurrentDirectory, "logs");
}
} else {
try {
Expand Down Expand Up @@ -225,7 +224,7 @@ static async Task<Int32> Main(String[] args) {
.UseHelp(ctx => {
ctx.HelpBuilder.CustomizeSymbol(pollingRateOption, secondColumnText: $"{pollingRateOption.Description} [default: 5]");
ctx.HelpBuilder.CustomizeSymbol(displayInfoOption, secondColumnText: $"{displayInfoOption.Description} [default: True]");
ctx.HelpBuilder.CustomizeSymbol(logfilePathOption, secondColumnText: $"{logfilePathOption.Description} [default: \".\"]");
ctx.HelpBuilder.CustomizeSymbol(logfilePathOption, secondColumnText: $@"{logfilePathOption.Description} [default: .\logs");
}).Build();

return await parser.InvokeAsync(args);
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
4 changes: 1 addition & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
- Added Logfile-Path command line + configuration file option
- Consolidated/Refactored logging method and output format
- Handled continued live time monitoring even if logging fails
- Fixed bug pertaining to defaulting of Logfile-Path when no option is supplied either through command-line or configuration.

0 comments on commit 0d5b67e

Please sign in to comment.