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

Added WrapLineLayoutRendererWrapper #1400

Merged
merged 7 commits into from
May 4, 2016
Merged

Added WrapLineLayoutRendererWrapper #1400

merged 7 commits into from
May 4, 2016

Conversation

mathieubrun
Copy link
Contributor

@304NotModified
Copy link
Member

Nice! Thanks!

@304NotModified
Copy link
Member

304NotModified commented Apr 26, 2016

needs some fix for .net35 ;)

LayoutRenderers\Wrappers\WrapLineLayoutRendererWrapper.cs(74,53): error CS1503: Argument 2: cannot convert from 'System.Collections.Generic.IEnumerable' to 'string[]' [C:\projects\nlog\src\NLog\NLog.netfx35.csproj

@304NotModified
Copy link
Member

@mathieubrun
Copy link
Contributor Author

@304NotModified I'll look into it. I also want to change a bit the MakeChunks method

@304NotModified
Copy link
Member

See the PR is send to you

@mathieubrun
Copy link
Contributor Author

Yes, thanks ! But I changed implementation to a simple StringBuilder. No need to split and join, much simplier :)

@304NotModified
Copy link
Member

That's indeed also a nice solution, if no unneeded stringbuilder are created :)

@mathieubrun
Copy link
Contributor Author

Done, waiting for AppVeyor to finish !

@codecov-io
Copy link

codecov-io commented Apr 26, 2016

Current coverage is 75.49%

Merging #1400 into master will increase coverage by +0.31%

  1. 2 files in src/NLog/Targets were modified. more
    • Misses -2
    • Partials +3
    • Hits +13
  2. 1 files in src/NLog were modified. more
    • Hits +5
  3. 5 files (not in diff) in src/NLog/Time were modified. more
  4. 13 files (not in diff) in ...Log/Targets/Wrappers were modified. more
    • Misses +1
    • Partials +3
    • Hits +25
  5. 22 files (not in diff) in src/NLog/Targets were modified. more
    • Misses -14
    • Partials +2
    • Hits +76
  6. 5 files (not in diff) in ...g/LogReceiverService were modified. more
    • Partials +1
    • Hits +4
  7. 9 files (not in diff) in src/NLog/Layouts were modified. more
    • Hits +4
  8. 14 files (not in diff) in ...utRenderers/Wrappers were modified. more
    • Partials +1
    • Hits +1
  9. 31 files (not in diff) in ...NLog/LayoutRenderers were modified. more
    • Partials +6
    • Hits +45
  10. 5 files (not in diff) in ...ernal/NetworkSenders were modified. more
    • Misses +12
    • Partials +2
    • Hits +7
@@           master      #1400   diff @@
========================================
  Files         267        268     +1   
  Lines       15607      16016   +409   
  Methods         0          0          
  Branches     1642       1729    +87   
========================================
+ Hits        11732      12091   +359   
- Misses       3492       3516    +24   
- Partials      383        409    +26   

Powered by Codecov. Last updated by e4d46be...e29b4f2

@304NotModified
Copy link
Member

A stringbuilder approach is indeed nicer, but also a bit more work too do it right.

var chunkLength = WrapLine;
var textLength = text.Length;

var sb = new StringBuilder(textLength);
Copy link
Member

Choose a reason for hiding this comment

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

building a stringbuilder isn't always needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed. replaced by a string

@304NotModified
Copy link
Member

Why is the string builder totally removed? I think we had a miscommunication!

The new stringbuilder wasn't needed if the line didn't need a wrap (e.g. length of 70). But in other cases a stringbuilder is more preferred than string concats

@mathieubrun
Copy link
Contributor Author

Ahah sorry, I understood to remove it fully :) I put it back

if (text.Length <= chunkLength) return text;

// preallocate correct number of chars
var result = new StringBuilder(text.Length + (text.Length / chunkLength) * Environment.NewLine.Length);
Copy link
Member

Choose a reason for hiding this comment

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

Good one!

@304NotModified
Copy link
Member

304NotModified commented May 1, 2016

Looks really good! This PR is Almost done!

Added some minor notes.

@304NotModified
Copy link
Member

I think I can merge this after we added some docs to the wiki?

@mathieubrun
Copy link
Contributor Author

I can write the new page, then you can link it on the https://github.com/NLog/NLog/wiki/Layout-Renderers page ?

@304NotModified
Copy link
Member

that would be great!

@mathieubrun
Copy link
Contributor Author

There you go : https://github.com/NLog/NLog/wiki/WrapLine-layout-renderer

I added tests for 2 other syntaxes :

${wrapline:${message}}
${wrapline:Inner=${message}:WrapLine=80}

@mathieubrun
Copy link
Contributor Author

I have no idea WHY commit 80f9e7d went without the method names...

@304NotModified
Copy link
Member

304NotModified commented May 2, 2016

lol that's weird indeed.

@304NotModified 304NotModified added this to the 4.3.4 milestone May 4, 2016
@304NotModified
Copy link
Member

Thanks for this great submit!

@304NotModified 304NotModified merged commit ac8190a into NLog:master May 4, 2016
@mathieubrun mathieubrun deleted the wrap-line-layout-renderer branch May 6, 2016 19:30
@mathieubrun
Copy link
Contributor Author

mathieubrun commented May 6, 2016

You're welcome ! I'll look if there are others I can help with !

@304NotModified
Copy link
Member

This has been released with NLog 4.3.4 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants