Skip to content
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

Bugfix forwarding logger #9650

Merged
merged 3 commits into from
Jan 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ public virtual void Initialize(IEventSource eventSource)

ParseParameters(eventSource);

ResetLoggerState();

if (!_forwardingSetFromParameters)
{
SetForwardingBasedOnVerbosity(eventSource);
Expand Down Expand Up @@ -291,33 +289,29 @@ private void SetForwardingBasedOnVerbosity(IEventSource eventSource)

/// <summary>
/// Returns the minimum importance of messages logged by this logger.
/// Forwarding logger might be configured to forward messages of particular importance regardless of the verbosity level of said logger.
/// This method properly reflects that.
/// </summary>
/// <returns>
/// The minimum message importance corresponding to this logger's verbosity or (MessageImportance.High - 1)
/// if this logger does not log messages of any importance.
/// The minimum message importance corresponding to this logger's verbosity or configuration of forwarding of messages of particular importance level.
/// If this logger is not configured to forward messages of any importance and verbosity is not explicitly set, then (MessageImportance.High - 1) is returned.
/// </returns>
internal MessageImportance GetMinimumMessageImportance()
{
return _verbosity switch
if (_forwardLowImportanceMessages)
{
LoggerVerbosity.Minimal => MessageImportance.High,
LoggerVerbosity.Normal => MessageImportance.Normal,
LoggerVerbosity.Detailed => MessageImportance.Low,
LoggerVerbosity.Diagnostic => MessageImportance.Low,

// The logger does not log messages of any importance.
LoggerVerbosity.Quiet => MessageImportance.High - 1,
_ => MessageImportance.High - 1,
};
}

/// <summary>
/// Reset the states of per-build member variables.
/// Used when a build is finished, but the logger might be needed for the next build.
/// </summary>
private void ResetLoggerState()
{
// No state needs resetting
return MessageImportance.Low;
}
if (_forwardNormalImportanceMessages)
{
return MessageImportance.Normal;
}
if (_forwardHighImportanceMessages)
{
return MessageImportance.High;
}
// The logger does not log messages of any importance.
return MessageImportance.High - 1;
}

/// <summary>
Expand Down