Skip to content

Commit fb3e8c6

Browse files
committed
(GH-179) Added console arguments for debug and verbose logging
1 parent 3d19342 commit fb3e8c6

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Source/GitReleaseManager.Cli/Logging/LogConfiguration.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void ConfigureLogging(BaseSubOptions options)
3131

3232
CreateDebugLogger(config);
3333
CreateConsoleInformationLogger(config, CONSOLE_INFO_TEMPLATE, _consoleTheme);
34-
CreateConsoleFullLogger(config, CONSOLE_FULL_TEMPLATE, _consoleTheme);
34+
CreateConsoleFullLogger(config, CONSOLE_FULL_TEMPLATE, _consoleTheme, options);
3535

3636
if (!string.IsNullOrEmpty(options.LogFilePath))
3737
{
@@ -41,13 +41,14 @@ public static void ConfigureLogging(BaseSubOptions options)
4141
Log.Logger = config.CreateLogger();
4242
}
4343

44-
private static void CreateConsoleFullLogger(LoggerConfiguration config, string consoleTemplate, ConsoleTheme consoleTheme)
44+
private static void CreateConsoleFullLogger(LoggerConfiguration config, string consoleTemplate, ConsoleTheme consoleTheme, BaseSubOptions options)
4545
{
4646
config.WriteTo.Logger((config) => config
4747
.Filter.ByExcluding((logEvent) => logEvent.Level == LogEventLevel.Information)
48+
.Filter.ByExcluding((logEvent) => !options.Debug && logEvent.Level == LogEventLevel.Debug)
49+
.Filter.ByExcluding((logEvent) => !options.Verbose && logEvent.Level == LogEventLevel.Verbose)
4850
.WriteTo.Console(
4951
outputTemplate: consoleTemplate,
50-
restrictedToMinimumLevel: LogEventLevel.Information,
5152
standardErrorFromLevel: LogEventLevel.Warning,
5253
theme: consoleTheme));
5354
}

Source/GitReleaseManager.Cli/Options/BaseSubOptions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ namespace GitReleaseManager.Cli.Options
1010

1111
public abstract class BaseSubOptions
1212
{
13-
[Option('d', "targetDirectory", HelpText = "The directory on which GitReleaseManager should be executed. Defaults to current directory.", Required = false)]
14-
public string TargetDirectory { get; set; }
13+
[Option("debug", HelpText = "Enable debugging console output")]
14+
public bool Debug { get; set; }
1515

1616
[Option('l', "logFilePath", HelpText = "Path to where log file should be created. Defaults to logging to console.", Required = false)]
1717
public string LogFilePath { get; set; }
1818

1919
[Option("no-logo", HelpText = "Disables the generation of the GRM commandline logo.", Required = false)]
2020
public bool NoLogo { get; set; }
21+
22+
[Option('d', "targetDirectory", HelpText = "The directory on which GitReleaseManager should be executed. Defaults to current directory.", Required = false)]
23+
public string TargetDirectory { get; set; }
24+
25+
[Option("verbose", HelpText = "Enabled verbose console output")]
26+
public bool Verbose { get; set; }
2127
}
2228
}

Source/GitReleaseManager.Cli/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,6 @@ private static IVcsProvider GetVcsProvider(BaseVcsOptions subOptions)
230230
}
231231

232232
private static void LogOptions(BaseSubOptions options)
233-
=> Log.Verbose("{@Options}", options);
233+
=> Log.Debug("{@Options}", options);
234234
}
235235
}

0 commit comments

Comments
 (0)