-
Notifications
You must be signed in to change notification settings - Fork 131
Add a way to get the configured log level switches #347
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
Changes from 1 commit
f768920
db9042f
2ecbe0a
3f459e1
c58ef69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Serilog.Core; | ||
|
||
namespace Serilog.Settings.Configuration; | ||
|
||
/// <summary> | ||
/// Contains information about the loaded configuration. | ||
/// </summary> | ||
public class LoadedConfiguration | ||
{ | ||
readonly IDictionary<string,LoggingLevelSwitch> _logLevelSwitches; | ||
|
||
internal LoadedConfiguration(IDictionary<string, LoggingLevelSwitch> logLevelSwitches) | ||
{ | ||
_logLevelSwitches = logLevelSwitches; | ||
} | ||
|
||
/// <summary> | ||
/// The log level switches that were loaded from the <c>LevelSwitches</c> section of the configuration. | ||
/// </summary> | ||
/// <remarks>The keys of the dictionary are the name of the switches without the leading <c>$</c> character.</remarks> | ||
public IReadOnlyDictionary<string, LoggingLevelSwitch> LogLevelSwitches => _logLevelSwitches.ToDictionary(e => e.Key.TrimStart('$'), e => e.Value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Property allocates There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it is worth worrying about the initial dollar sign in the name. In fact, this is part of the switch name. What is the goal in removal of the dollar sign? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Well, this is debatable: the {
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"LevelSwitches": { "controlSwitch": "Verbose" },
I wouldn't worry too much about that, one call is made per call to Also, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Then it makes no sense in cutting off the dollar sign if it is not a special symbol. Why to do this? Just return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have addressed this concern in 2ecbe0a. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 $ should be appended in tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course! Fixed in 3f459e1. |
||
} |
Uh oh!
There was an error while loading. Please reload this page.