-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added a message of enabled logs, and their paths. #13577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
a93b3f1
49bb7f1
6f3fbbd
54be972
1f7c117
a598edd
4aff18e
f3037a6
98219f3
b9209d2
3c610fb
875ce4f
04acb06
7e2f60f
42b7457
5a46865
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| using Microsoft.Build.Experimental.BuildCheck.Infrastructure; | ||
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Framework.Profiler; | ||
| using Microsoft.Build.Logging; | ||
| using Microsoft.Build.Shared; | ||
|
|
||
| using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException; | ||
|
|
@@ -360,6 +361,13 @@ public void LogBuildStarted() | |
|
|
||
| // Make sure we process this event before going any further | ||
| WaitForLoggingToProcessEvents(); | ||
|
|
||
| // Register Loggers and print out all the enabled loggers. | ||
| if (!OnlyLogCriticalEvents) | ||
| { | ||
| LogEnabledLoggers(); | ||
| RegisterLoggers(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It pains me to iterate the list twice. Could you collapse these to one method that emits both messages?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, will do. |
||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -391,6 +399,62 @@ public void LogBuildFinished(bool success) | |
| WaitForLoggingToProcessEvents(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Logs the names of enabled logs (except for Forwarding logs). | ||
| /// </summary> | ||
| private void LogEnabledLoggers() | ||
| { | ||
| List<string> listOfLoggers = new(); | ||
| foreach (ILogger logger in Loggers) | ||
| { | ||
| ILogger actualLogger = UnwrapLogger(logger); | ||
| if (actualLogger is CentralForwardingLogger == true) | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| { | ||
| continue; | ||
| } | ||
| listOfLoggers.Add(actualLogger.GetType().Name); | ||
| } | ||
| if (listOfLoggers.Count != 0) | ||
| { | ||
| var msgEvent = new BuildMessageEventArgs( | ||
| ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("LogEnabledLogs", string.Join(", ", listOfLoggers)), | ||
| null, null, MessageImportance.Low); | ||
| msgEvent.BuildEventContext = BuildEventContext.Invalid; | ||
| ProcessLoggingEvent(msgEvent); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Logs the file paths of enabled logs. | ||
| /// </summary> | ||
| private void RegisterLoggers() | ||
| { | ||
| foreach (ILogger logger in Loggers) | ||
| { | ||
| ILogger actualLogger = UnwrapLogger(logger); | ||
|
|
||
| string outputFilePath = actualLogger is IFileOutputLogger fileLogger && !string.IsNullOrEmpty(fileLogger.OutputFilePath) | ||
| ? fileLogger.OutputFilePath | ||
| : null; | ||
|
|
||
| IReadOnlyList<string> additionalPaths = actualLogger is BinaryLogger bl | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| ? bl.AdditionalFilePaths | ||
| : null; | ||
|
|
||
| var registerEvent = new LoggerRegisteredEventArgs( | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| loggerName: actualLogger.GetType().Name, | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| outputFilePath: outputFilePath, | ||
| verbosity: actualLogger.Verbosity, | ||
| additionalOutputFilePaths: additionalPaths); | ||
| registerEvent.BuildEventContext = BuildEventContext.Invalid; | ||
| ProcessLoggingEvent(registerEvent); | ||
| } | ||
| } | ||
| private ILogger UnwrapLogger(ILogger logger) | ||
| { | ||
| return logger is ReusableLogger reusable ? reusable.OriginalLogger : logger; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void LogBuildCanceled() | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.Build.Logging | ||
| { | ||
| internal interface IFileOutputLogger | ||
| { | ||
| string OutputFilePath { get; } | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.