-
Notifications
You must be signed in to change notification settings - Fork 320
Fix LogLevel: CLI phase suppression and case-insensitive "Default" config key #3203
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
Merged
+165
−36
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d4ad8a3
Initial plan
Copilot 36bfd9a
Fix LogLevel incorrect behavior: CLI phase messages and case-insensit…
Copilot 6188dc7
Fix log level logic
RubenCerna2079 ad13f1f
Remove unnecessary code
RubenCerna2079 caabc06
Merge branch 'main' into copilot/fix-loglevel-incorrect-behavior
RubenCerna2079 fe81966
Add missing new classes
RubenCerna2079 493a322
Merge remote-tracking branch 'refs/remotes/origin/copilot/fix-logleve…
RubenCerna2079 9e0c115
Add missing service
RubenCerna2079 1f4ee8d
Fix syntax
RubenCerna2079 6f3b5bb
Merge branch 'main' into copilot/fix-loglevel-incorrect-behavior
RubenCerna2079 bf9cfd7
Make changes based on comments
RubenCerna2079 eb6b4fd
Merge branch 'main' into copilot/fix-loglevel-incorrect-behavior
RubenCerna2079 e1bc280
Merge branch 'main' into copilot/fix-loglevel-incorrect-behavior
Aniruddh25 1c85d6c
Add helper method
RubenCerna2079 88e235a
Merge branch 'main' into copilot/fix-loglevel-incorrect-behavior
RubenCerna2079 5994db0
Merge remote-tracking branch 'refs/remotes/origin/copilot/fix-logleve…
RubenCerna2079 766aa35
Merge branch 'main' into copilot/fix-loglevel-incorrect-behavior
anushakolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Concurrent; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Azure.DataApiBuilder.Config | ||
| { | ||
| /// <summary> | ||
| /// A general-purpose log buffer that stores log entries before the final log level is determined. | ||
| /// Can be used across different components during startup to capture important early logs. | ||
| /// </summary> | ||
| public class StartupLogBuffer | ||
| { | ||
| private readonly ConcurrentQueue<(LogLevel LogLevel, string Message)> _logBuffer; | ||
| private readonly object _flushLock = new(); | ||
|
|
||
| public StartupLogBuffer() | ||
| { | ||
| _logBuffer = new(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Buffers a log entry with a specific category name. | ||
| /// </summary> | ||
| public void BufferLog(LogLevel logLevel, string message) | ||
| { | ||
| _logBuffer.Enqueue((logLevel, message)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Flushes all buffered logs to a single target logger. | ||
| /// </summary> | ||
| public void FlushToLogger(ILogger? targetLogger) | ||
| { | ||
| lock (_flushLock) | ||
| { | ||
| while (_logBuffer.TryDequeue(out (LogLevel LogLevel, string Message) entry)) | ||
| { | ||
| targetLogger?.Log(entry.LogLevel, message: entry.Message); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using Azure.DataApiBuilder.Config.ObjectModel; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Azure.DataApiBuilder.Service.Telemetry | ||
| { | ||
| public class DynamicLogLevelProvider | ||
| { | ||
| public LogLevel CurrentLogLevel { get; private set; } | ||
| public bool IsCliOverridden { get; private set; } | ||
|
|
||
| public void SetInitialLogLevel(LogLevel logLevel = LogLevel.Error, bool isCliOverridden = false) | ||
| { | ||
| CurrentLogLevel = logLevel; | ||
| IsCliOverridden = isCliOverridden; | ||
| } | ||
|
|
||
| public void UpdateFromRuntimeConfig(RuntimeConfig runtimeConfig) | ||
| { | ||
| // Only update if CLI didn't override | ||
| if (!IsCliOverridden) | ||
RubenCerna2079 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| CurrentLogLevel = runtimeConfig.GetConfiguredLogLevel(); | ||
| } | ||
| } | ||
|
|
||
| public bool ShouldLog(LogLevel logLevel) | ||
| { | ||
| return logLevel >= CurrentLogLevel; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.