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

Escaping curly braces in log messages #1547

Closed
DixonDs opened this issue Mar 27, 2017 · 5 comments
Closed

Escaping curly braces in log messages #1547

DixonDs opened this issue Mar 27, 2017 · 5 comments
Milestone

Comments

@DixonDs
Copy link
Contributor

DixonDs commented Mar 27, 2017

It seems that is not possible to escape curly braces properly in log messages.

  1. Information("{} {0}", 123); leads to error "Error: Input string was not in a correct format."
  2. Information("{{}} {0}", 123); outputs "{{}} 123". The same input to string.Format yields "{} 123" which is what I want to get.

This is related to SharpeRAD/Cake.Powershell#25 when the powershell output contains this particular string "{}"

kcamp added a commit to kcamp/cake that referenced this issue Mar 29, 2017
kcamp added a commit to kcamp/cake that referenced this issue Mar 29, 2017
@kcamp
Copy link
Contributor

kcamp commented Mar 29, 2017

I've made a first pass over this bug and think the changes I've made at 88b2f9d represent the appropriate solution. I've added the tests that cover the two use-cases referenced above.

The one thing that I think this exposes is a bug in the LiteralToken that is being returned for escaped curlies -

Information("{{}} {0}", 123); outputs "{{}} 123"

@DixonDs is right in that this should probably output {} 123 to be consistent with expectations, namely the implementation of string.Format. I have adjusted the parser to return a single '{' or '}' in those cases and updated the tests to match.

If this seems reasonable, I will create a PR with the changes.

kcamp added a commit to kcamp/cake that referenced this issue Apr 8, 2017
@devlead
Copy link
Member

devlead commented Oct 1, 2017

@kcamp Can you submit a PR we can review?

@kcamp
Copy link
Contributor

kcamp commented Oct 2, 2017

@devlead Sure, will have that put together in the next day or so.

@devlead
Copy link
Member

devlead commented Oct 2, 2017

@kcamp excellent! 👍

kcamp added a commit to kcamp/cake that referenced this issue Oct 6, 2017
devlead pushed a commit to kcamp/cake that referenced this issue Oct 7, 2017
@devlead devlead added this to the v0.23.0 milestone Oct 7, 2017
@devlead devlead added Improvement and removed Bug labels Oct 7, 2017
@devlead
Copy link
Member

devlead commented Oct 7, 2017

Fixed by #1863

@devlead devlead closed this as completed Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants