Skip to content

Commit

Permalink
(GitTools#439) Add option to disable warning to stderr
Browse files Browse the repository at this point in the history
This updates the handling of how we output log messages to the console
to instead of blindly outputting warning messages to stderr all the
time, it will instead check if an environment variable called `CI` is
available and set to true, or the user themself have specified the
`--ci` argument.

When CI system is detected, any warnings will instead be outputted to
the normal stdout along with normal informational messages.
  • Loading branch information
AdmiringWorm committed Feb 8, 2024
1 parent a94d9d5 commit 6d0b8c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Cli/Logging/LogConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static void CreateConsoleFullLogger(LoggerConfiguration config, string c
.Filter.ByExcluding((logEvent) => !options.Verbose && logEvent.Level == LogEventLevel.Verbose)
.WriteTo.Console(
outputTemplate: consoleTemplate,
standardErrorFromLevel: LogEventLevel.Warning,
standardErrorFromLevel: options.IsCISystem ? LogEventLevel.Error : LogEventLevel.Warning,
theme: consoleTheme));
}

Expand Down
15 changes: 15 additions & 0 deletions src/GitReleaseManager.Core/Options/BaseSubOptions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
using System;
using CommandLine;

namespace GitReleaseManager.Core.Options
{
public abstract class BaseSubOptions
{
protected BaseSubOptions()
{
var ciEnvironmentVariable = Environment.GetEnvironmentVariable("CI");

bool isCiSystem;
if (!string.IsNullOrEmpty(ciEnvironmentVariable) && bool.TryParse(ciEnvironmentVariable, out isCiSystem))
{
IsCISystem = isCiSystem;
}
}

[Option("debug", HelpText = "Enable debugging console output")]
public bool Debug { get; set; }

Expand All @@ -18,5 +30,8 @@ public abstract class BaseSubOptions

[Option("verbose", HelpText = "Enable verbose console output")]
public bool Verbose { get; set; }

[Option("ci", HelpText = "Configure GitReleaseManager to be compatible with CI systems")]
public bool IsCISystem { get; set; }
}
}

0 comments on commit 6d0b8c3

Please sign in to comment.