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

Fix broken logging when -Message array includes a format operation. #102

Merged
merged 2 commits into from
Feb 5, 2018
Merged

Fix broken logging when -Message array includes a format operation. #102

merged 2 commits into from
Feb 5, 2018

Conversation

danbelcher-MSFT
Copy link
Contributor

  • Fix broken logging when -Message array includes a format operation.

After the recent changes to Write-Log, logging was broken for specific cases where -Message was an arrayband included a format operation. The issue was our misunderstanding of the functionality of the format operator. The operator can operate with an array on the left-hand side. In this case, the elements of the array are joined and each string in the array may be formatted. When using the format operation while trying to create an array, we were inadvertently joining the contents of the array into a single string when we actually intended the format operation to be restricted to one line of the array.

The fix is to wrap the format operation in parentheses, to make the expression explicit. In the future, we should be more diligent about using parentheses for the same effect.

Daniel Belcher added 2 commits February 5, 2018 11:56
After the recent changes to Write-Log, logging was broken for specific cases where -Message was an array
and included a format operation. The issue was our misunderstanding of the functionality of the format operator.
The operator can operate with an array on the left-hand side. In this case, the elements of the array are joined
and each string in the array may be formatted. When using the format operation while trying to create an array,
we were inadvertently joining the contents of the array into a single string when we actually intended the format
operation to be restricted to one line of the array.

The fix is to wrap the format operation in parentheses, to make the expression explicit. In the future, we should be
more diligent about using parentheses for the same effect.
Copy link
Member

@HowardWolosky HowardWolosky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@danbelcher-MSFT danbelcher-MSFT merged commit 95b2cd9 into microsoft:master Feb 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants