-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Restored SetupFromEnvironmentVariables #5709
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
Conversation
WalkthroughThis change introduces new configuration methods to the internal logger. In the NLog library, two public extension methods have been added: one to reset the logger configuration and another to set it up using environment variables and App.config. In addition, several private helper functions have been implemented to retrieve and validate configuration values with error handling. New unit tests ensure that both the environment-based setup and the reset functionality work as expected. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant S as SetupInternalLoggerBuilderExtensions
participant E as Environment/App.config
participant H as Helper Methods
C->>S: SetupFromEnvironmentVariables()
S->>E: Retrieve configuration values
E-->>S: Return config values
S->>H: Parse & validate values
H-->>S: Return parsed configuration
S-->>C: Return configured logger builder
sequenceDiagram
participant C as Client
participant S as SetupInternalLoggerBuilderExtensions
C->>S: ResetConfig()
S-->>C: Logger configuration reset successfully
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/NLog/SetupInternalLoggerBuilderExtensions.cs (1)
111-113
: Fix typo in XML documentation.The word "varialbes" is misspelled in the documentation.
- /// Resets the InternalLogger configuration without resolving default values from Environment-varialbes or App.config + /// Resets the InternalLogger configuration without resolving default values from Environment-variables or App.configtests/NLog.UnitTests/Config/LogFactorySetupTests.cs (2)
567-588
: Consider adding more test cases.While the test verifies basic functionality, consider adding test cases for:
- Different environment variable values
- Invalid environment variable values
- Missing environment variables
- Conflicting app.config and environment variable values
590-611
: Consider testing more properties.The test only verifies
IncludeTimestamp
andLogLevel
. Consider testing other properties that are reset:
- LogToConsole
- LogToConsoleError
- LogFile
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/NLog/SetupInternalLoggerBuilderExtensions.cs
(2 hunks)tests/NLog.UnitTests/Config/LogFactorySetupTests.cs
(1 hunks)
🔇 Additional comments (3)
src/NLog/SetupInternalLoggerBuilderExtensions.cs (3)
120-148
: LGTM! Well-documented and consistent implementation.The method follows a consistent pattern for retrieving settings and includes comprehensive documentation of supported environment variables and app.config settings.
150-166
: LGTM! Well-structured platform-specific implementation.The method correctly uses preprocessor directives for .NET Framework specific code and includes proper error handling.
168-199
: LGTM! Robust error handling and type conversion.The implementation includes:
- Proper error handling with
MustBeRethrownImmediately()
- Graceful fallback to environment variables
- Type-safe conversion with proper culture handling
Also applies to: 224-245
|
No description provided.