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
${level} add format option (full, single char and ordinal) #2034
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2034 +/- ##
=======================================
+ Coverage 82% 82% +<1%
=======================================
Files 286 286
Lines 19663 19670 +7
Branches 2309 2310 +1
=======================================
+ Hits 16042 16048 +6
Misses 3056 3056
- Partials 565 566 +1 Continue to review full report at Codecov.
|
cool! Thanks! Could you place the to sync the csproj files, see https://github.com/NLog/NLog/blob/master/CONTRIBUTING.md#sync-projects |
@@ -46,13 +48,44 @@ namespace NLog.LayoutRenderers | |||
public class LevelLayoutRenderer : LayoutRenderer | |||
{ | |||
/// <summary> | |||
/// A value indicating when the cache is cleared. |
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.
I think this is wrong docs?
[Flags] | ||
public enum LevelOutputOption | ||
{ | ||
/// <summary>Ouput the name as the level.</summary> |
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.
Proposal:
- render the full level name
- render the first character for the level
- render the ordinal (aka number) for the level.
/// Gets or sets a value indicating how the level is output. | ||
/// </summary> | ||
[DefaultValue(LevelOutputOption.Name)] | ||
public LevelOutputOption LevelOutput { get; set; } |
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.
I was thinking of "format", what do you think?
logger.Error("a"); | ||
AssertDebugLastMessage("debug", "E a"); | ||
logger.Fatal("a"); | ||
AssertDebugLastMessage("debug", "F a"); |
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 good! please add "trace"
logger.Error("a"); | ||
AssertDebugLastMessage("debug", "4 a"); | ||
logger.Fatal("a"); | ||
AssertDebugLastMessage("debug", "5 a"); |
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.
also please add trace
You're welcome :) I like your suggestion to name it Format, so I renamed the enum to LevelFormat and moved it to its own file. I modeled it after StackTraceFormat, so hopefully it follows the style. I also removed the wrong doc and updated the unit tests to add trace. Let me know if you need anything else to accept. |
Looks ready to merge! Could you please update the docs? Thanks! Just add it to the wiki, with "introduced in 4.4.6". Maybe we should add the table with Short name and ordinal. |
docs see #2043 Will merge this an release a beta |
Thanks! I have updated the docs with the new parameter and added a condensed table. |
FYI, NLog 4.4.6 is live! |
Adds single character and ordinal level output options to the LevelLayoutRenderer to address #1949 and #1950