Skip to content

Commit 0d72bbf

Browse files
committed
Merge pull request #176 from JakeGinnivan/ConsoleImprovements
Console improvements
2 parents 110f2e5 + 347abcd commit 0d72bbf

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

GitVersionExe/Program.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ static void Main()
3636
return;
3737
}
3838

39+
if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec))
40+
arguments.Output = OutputType.BuildServer;
41+
3942
ConfigureLogging(arguments);
4043

4144
var gitPreparer = new GitPreparer(arguments);
@@ -142,11 +145,16 @@ static IEnumerable<IBuildServer> GetApplicableBuildServers(Arguments arguments)
142145

143146
static void ConfigureLogging(Arguments arguments)
144147
{
145-
Action<string> writeAction = x => { };
148+
var writeActions = new List<Action<string>>();
149+
150+
if (arguments.Output == OutputType.BuildServer)
151+
{
152+
writeActions.Add(Console.WriteLine);
153+
}
146154

147155
if (arguments.LogFilePath == "console")
148156
{
149-
writeAction = Console.WriteLine;
157+
writeActions.Add(Console.WriteLine);
150158
}
151159
else if (arguments.LogFilePath != null)
152160
{
@@ -158,17 +166,17 @@ static void ConfigureLogging(Arguments arguments)
158166
using (File.CreateText(arguments.LogFilePath)) { }
159167
}
160168

161-
writeAction = x => WriteLogEntry(arguments, x);
169+
writeActions.Add(x => WriteLogEntry(arguments, x));
162170
}
163171
catch (Exception ex)
164172
{
165173
Console.WriteLine("Failed to configure logging: " + ex.Message);
166174
}
167175
}
168176

169-
Logger.WriteInfo = writeAction;
170-
Logger.WriteWarning = writeAction;
171-
Logger.WriteError = writeAction;
177+
Logger.WriteInfo = s => writeActions.ForEach(a => a(s));
178+
Logger.WriteWarning = s => writeActions.ForEach(a => a(s));
179+
Logger.WriteError = s => writeActions.ForEach(a => a(s));
172180
}
173181

174182
static void WriteLogEntry(Arguments arguments, string s)

0 commit comments

Comments
 (0)