-
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
Open
AlesProkop
wants to merge
16
commits into
dotnet:main
Choose a base branch
from
AlesProkop:notify-file-names-of-logs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a93b3f1
Added a message of enabled logs, and their paths.
49bb7f1
separated the function, added interface for handling file names
6f3fbbd
First draft of paths of logs in BuildSummary.
54be972
Added clickable links into the build summary.
1f7c117
messages added into summary. added files into binarylog.
a598edd
adressed copilot review
4aff18e
adressed build issues and comments
f3037a6
changed inheritance, added binary log handling
98219f3
adressed failing unit tests
b9209d2
adressing comments
3c610fb
Merge branch 'main' into notify-file-names-of-logs
AlesProkop 875ce4f
fixed localization files
04acb06
updated xlf
7e2f60f
fix failing unit tests
42b7457
addressing comments
5a46865
collapsed registration, reverted xlf,resx
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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,66 @@ 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); | ||
| 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() | ||
| { | ||
| var loggerDescriptions = new List<RegisteredLoggerInfo>(); | ||
| foreach (ILogger logger in Loggers) | ||
| { | ||
| ILogger actualLogger = UnwrapLogger(logger); | ||
|
|
||
| var outputFilePaths = new List<string>(); | ||
| if (actualLogger is IFileOutputLogger fileLogger && !string.IsNullOrEmpty(fileLogger.OutputFilePath)) | ||
| { | ||
| outputFilePaths.Add(fileLogger.OutputFilePath); | ||
| } | ||
|
|
||
| if (actualLogger is BinaryLogger bl && bl.AdditionalFilePaths != null) | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| { | ||
| outputFilePaths.AddRange(bl.AdditionalFilePaths); | ||
| } | ||
|
|
||
| loggerDescriptions.Add(new RegisteredLoggerInfo( | ||
| loggerName: actualLogger.GetType().Name, | ||
|
AlesProkop marked this conversation as resolved.
Outdated
|
||
| outputFilePaths: outputFilePaths.Count > 0 ? outputFilePaths : null, | ||
| verbosity: actualLogger.Verbosity)); | ||
| } | ||
|
|
||
| if (loggerDescriptions.Count > 0) | ||
| { | ||
| var registerEvent = new LoggerRegisteredEventArgs(loggerDescriptions); | ||
| registerEvent.BuildEventContext = BuildEventContext.Invalid; | ||
| ProcessLoggingEvent(registerEvent); | ||
| } | ||
| } | ||
| private ILogger UnwrapLogger(ILogger logger) | ||
| { | ||
| return logger is ReusableLogger reusable ? reusable.OriginalLogger : logger; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void LogBuildCanceled() | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
|
||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.