Skip to content

Commit

Permalink
C#: Reduce nuget and razor logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnebel committed Apr 15, 2024
1 parent 336a18a commit 8915241
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private bool TryRestoreNugetPackage(string package)
};

var threadId = Environment.CurrentManagedThreadId;
void onOut(string s) => logger.LogInfo(s, threadId);
void onOut(string s) => logger.LogDebug(s, threadId);
void onError(string s) => logger.LogError(s, threadId);
var exitCode = pi.ReadOutput(out var _, onOut, onError);
if (exitCode != 0)
Expand Down Expand Up @@ -235,7 +235,7 @@ private void RunMonoNugetCommand(string command, out IList<string> stdout)
};

var threadId = Environment.CurrentManagedThreadId;
void onOut(string s) => logger.LogInfo(s, threadId);
void onOut(string s) => logger.LogDebug(s, threadId);
void onError(string s) => logger.LogError(s, threadId);
pi.ReadOutput(out stdout, onOut, onError);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ public IEnumerable<string> GenerateFiles(IEnumerable<string> cshtmls, IEnumerabl

try
{
logger.LogInfo("Produce analyzer config content.");
GenerateAnalyzerConfig(cshtmls, analyzerConfig);

logger.LogInfo($"Analyzer config content: {File.ReadAllText(analyzerConfig)}");
logger.LogDebug($"Analyzer config content: {File.ReadAllText(analyzerConfig)}");

var args = new StringBuilder();
args.Append($"/target:exe /generatedfilesout:\"{outputFolder}\" /out:\"{dllPath}\" /analyzerconfig:\"{analyzerConfig}\" ");
Expand All @@ -88,7 +89,8 @@ public IEnumerable<string> GenerateFiles(IEnumerable<string> cshtmls, IEnumerabl

var argsString = args.ToString();

logger.LogInfo($"Running CSC to generate Razor source files with arguments: {argsString}.");
logger.LogInfo($"Running CSC to generate Razor source files.");
logger.LogDebug($"Running CSC to generate Razor source files with arguments: {argsString}.");

using (var sw = new StreamWriter(cscArgsPath))
{
Expand Down Expand Up @@ -126,4 +128,4 @@ private void DeleteFile(string path)
}
}
}
}
}

0 comments on commit 8915241

Please sign in to comment.