Skip to content

Commit 12c1050

Browse files
committed
Exclude some messages from the binlog
1 parent e54f76e commit 12c1050

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/Compilers/Core/MSBuildTask/ManagedCompiler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,9 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string
540540

541541
_sharedCompileCts = new CancellationTokenSource();
542542
logger.Log($"CommandLine = '{commandLineCommands}'");
543-
logger.Log($"BuildResponseFile = '{responseFileCommands}'");
543+
logger.Log($"BuildResponseFile = '{responseFileCommands}'",
544+
// Command line args can be long and are already included in the binlog.
545+
excludeFromBinlog: true);
544546

545547
var clientDirectory = Path.GetDirectoryName(PathToBuiltInTool);
546548
if (clientDirectory is null || tempDirectory is null)
@@ -813,7 +815,7 @@ private void LogCompilationMessage(ICompilerServerLogger logger, string requestI
813815
var message = $"CompilerServer: {category} - {diagnostic} - {requestId}";
814816
if (kind == CompilationKind.FatalError)
815817
{
816-
logger.LogError(message);
818+
logger.LogError(message, excludeFromBinlog: true);
817819
Log.LogError(message);
818820
}
819821
else

src/Compilers/Core/MSBuildTask/TaskCompilerServerLogger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ internal sealed class TaskCompilerServerLogger(
2020

2121
public bool IsLogging => true;
2222

23-
public void Log(string message)
23+
public void Log(string message, bool excludeFromBinlog = false)
2424
{
2525
_inner.Log(message);
26-
_taskLogger.LogMessage(message);
26+
if (!excludeFromBinlog) _taskLogger.LogMessage(message);
2727
}
2828
}

src/Compilers/Shared/CompilerServerLogger.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Microsoft.CodeAnalysis.CommandLine
2424
internal interface ICompilerServerLogger
2525
{
2626
bool IsLogging { get; }
27-
void Log(string message);
27+
void Log(string message, bool excludeFromBinlog = false);
2828
}
2929

3030
internal static class CompilerServerLoggerExtensions
@@ -37,11 +37,11 @@ internal static void Log(this ICompilerServerLogger logger, string format, param
3737
}
3838
}
3939

40-
internal static void LogError(this ICompilerServerLogger logger, string message)
40+
internal static void LogError(this ICompilerServerLogger logger, string message, bool excludeFromBinlog = false)
4141
{
4242
if (logger.IsLogging)
4343
{
44-
logger.Log($"Error: {message}");
44+
logger.Log($"Error: {message}", excludeFromBinlog: excludeFromBinlog);
4545
}
4646
}
4747

@@ -146,7 +146,7 @@ public void Dispose()
146146
_loggingStream = null;
147147
}
148148

149-
public void Log(string message)
149+
public void Log(string message, bool excludeFromBinlog = false)
150150
{
151151
if (_loggingStream is object)
152152
{
@@ -174,7 +174,7 @@ private EmptyCompilerServerLogger()
174174
{
175175
}
176176

177-
public void Log(string message)
177+
public void Log(string message, bool excludeFromBinlog = false)
178178
{
179179
}
180180
}

0 commit comments

Comments
 (0)