Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions GitVersionExe/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ static void Main()
return;
}

if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec))
arguments.Output = OutputType.BuildServer;

ConfigureLogging(arguments);

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

static void ConfigureLogging(Arguments arguments)
{
Action<string> writeAction = x => { };
var writeActions = new List<Action<string>>();

if (arguments.Output == OutputType.BuildServer)
{
writeActions.Add(Console.WriteLine);
}

if (arguments.LogFilePath == "console")
{
writeAction = Console.WriteLine;
writeActions.Add(Console.WriteLine);
}
else if (arguments.LogFilePath != null)
{
Expand All @@ -158,17 +166,17 @@ static void ConfigureLogging(Arguments arguments)
using (File.CreateText(arguments.LogFilePath)) { }
}

writeAction = x => WriteLogEntry(arguments, x);
writeActions.Add(x => WriteLogEntry(arguments, x));
}
catch (Exception ex)
{
Console.WriteLine("Failed to configure logging: " + ex.Message);
}
}

Logger.WriteInfo = writeAction;
Logger.WriteWarning = writeAction;
Logger.WriteError = writeAction;
Logger.WriteInfo = s => writeActions.ForEach(a => a(s));
Logger.WriteWarning = s => writeActions.ForEach(a => a(s));
Logger.WriteError = s => writeActions.ForEach(a => a(s));
}

static void WriteLogEntry(Arguments arguments, string s)
Expand Down