Skip to content

Commit 6d0b8c3

Browse files
committed
(GitTools#439) Add option to disable warning to stderr
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.
1 parent a94d9d5 commit 6d0b8c3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/GitReleaseManager.Cli/Logging/LogConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private static void CreateConsoleFullLogger(LoggerConfiguration config, string c
4343
.Filter.ByExcluding((logEvent) => !options.Verbose && logEvent.Level == LogEventLevel.Verbose)
4444
.WriteTo.Console(
4545
outputTemplate: consoleTemplate,
46-
standardErrorFromLevel: LogEventLevel.Warning,
46+
standardErrorFromLevel: options.IsCISystem ? LogEventLevel.Error : LogEventLevel.Warning,
4747
theme: consoleTheme));
4848
}
4949

src/GitReleaseManager.Core/Options/BaseSubOptions.cs

+15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
using System;
12
using CommandLine;
23

34
namespace GitReleaseManager.Core.Options
45
{
56
public abstract class BaseSubOptions
67
{
8+
protected BaseSubOptions()
9+
{
10+
var ciEnvironmentVariable = Environment.GetEnvironmentVariable("CI");
11+
12+
bool isCiSystem;
13+
if (!string.IsNullOrEmpty(ciEnvironmentVariable) && bool.TryParse(ciEnvironmentVariable, out isCiSystem))
14+
{
15+
IsCISystem = isCiSystem;
16+
}
17+
}
18+
719
[Option("debug", HelpText = "Enable debugging console output")]
820
public bool Debug { get; set; }
921

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

1931
[Option("verbose", HelpText = "Enable verbose console output")]
2032
public bool Verbose { get; set; }
33+
34+
[Option("ci", HelpText = "Configure GitReleaseManager to be compatible with CI systems")]
35+
public bool IsCISystem { get; set; }
2136
}
2237
}

0 commit comments

Comments
 (0)