-
Notifications
You must be signed in to change notification settings - Fork 143
SCAN4NET-96 and SCAN4NET-97: Fix logger timestamp duplication #2212
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
Conversation
417670e
to
a5c35f6
Compare
public void AssertExpectedLastMessageRegex(string expected) | ||
{ | ||
var lastMessage = GetLastMessage(outputWriter); | ||
lastMessage.Should().MatchRegex(expected, "Expected message was not logged"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to match the timestamp abstractly, as it does not have a concrete, static value.
@@ -111,7 +111,7 @@ public void ResumeOutput() | |||
} | |||
|
|||
public void LogWarning(string message, params object[] args) => | |||
Write(MessageType.Warning, GetFormattedMessage(Resources.Logger_WarningPrefix + message, args)); | |||
Write(MessageType.Warning, Resources.Logger_WarningPrefix + message, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were three bugs with this file:
LogWarning
ANDLogUIWarning
used to callGetFormattedMessage
. Every invocation adds one more timestamp, and since theUI
method calls the normal warning one, we would get 2 of them.Write
would add one moreGetFormattedMessage
on the top, so we would get 3 of them.FlushOutput
then would also callGetFormattedMessage
, so we would get 4 of them.
My refactoring does the following two main steps:
- The only place where
GetFormattedMessage
is allowed to be called is insideWrite
. This means everyLog
method falls-through toWrite
, where the formatting happens. - The
FlushOutput
does not callWrite
at all, but a method that is wrapped byWrite
, which already expects the message to be formatted.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
SCAN4NET-96
SCAN4NET-97