Skip to content

Change CLI flag --LogLevel to --log-level#3653

Open
RubenCerna2079 wants to merge 7 commits into
mainfrom
dev/rubencerna/fix-cli-loglevel-flag
Open

Change CLI flag --LogLevel to --log-level#3653
RubenCerna2079 wants to merge 7 commits into
mainfrom
dev/rubencerna/fix-cli-loglevel-flag

Conversation

@RubenCerna2079

Copy link
Copy Markdown
Contributor

Why make this change?

What is this change?

We changed the dab start --LogLevel flag to --log-level in order to have it follow the conventions we already have. We also allow for the CLI to still use the previous --LogLevel flag but add a warning sign to ensure the user knows it is deprecated. Lastly, also changed all of the comments that mention the previous --LogLevel and updated it to use the new --log-level.

How was this tested?

  • Integration Tests
  • Unit Tests
    Changed the tests that were for --LogLevel so they now use --log-level and added a few extra cases to ensure the --LogLevel flag still works

Sample Request(s)

dab start --log-level information
dab start --LogLevel warning

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes the dab start logging flag to --log-level to align with the CLI’s kebab-case conventions, while retaining the legacy --LogLevel as a deprecated alias and updating internal documentation/tests accordingly.

Changes:

  • Renamed the dab start flag from --LogLevel to --log-level and introduced a hidden legacy option (--LogLevel) with a deprecation warning.
  • Updated CLI/service log-level plumbing to pass --log-level through to the engine and refreshed comments/docs to match.
  • Updated unit/end-to-end tests to use --log-level, adding coverage for the legacy flag still functioning.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Service/Startup.cs Updates comments to reference the new --log-level startup argument.
src/Service/Program.cs Updates service-side CLI arg parsing/docs to use --log-level for log level initialization.
src/Service.Tests/UnitTests/DynamicLogLevelProviderTests.cs Updates test docs to reference --log-level.
src/Core/Telemetry/ILogLevelController.cs Updates interface docs for precedence to reference --log-level.
src/Cli/Utils.cs Updates CLI state/docs to reference --log-level.
src/Cli/Properties/launchSettings.json Modifies CLI debug profile arguments (currently includes a machine-specific path).
src/Cli/Program.cs Updates early flag parsing to detect --log-level before logger creation.
src/Cli/Exporter.cs Updates StartOptions construction to include new legacy parameter.
src/Cli/CustomLoggerProvider.cs Updates comments to reference --log-level behavior in MCP stdio mode.
src/Cli/ConfigGenerator.cs Implements legacy --LogLevel handling with a deprecation warning and forwards --log-level to the engine.
src/Cli/Commands/StartOptions.cs Adds --log-level option and a hidden legacy --LogLevel option.
src/Cli.Tests/EndToEndTests.cs Updates E2E tests to use --log-level and adds legacy --LogLevel cases.
src/Cli.Tests/CustomLoggerTests.cs Updates test docs to reference --log-level.
src/Azure.DataApiBuilder.Mcp/Core/McpStdioServer.cs Updates MCP docs/comments to reference --log-level.
Comments suppressed due to low confidence (1)

src/Cli/Program.cs:67

  • ParseEarlyFlags only detects the new --log-level flag. If a user uses the legacy --LogLevel flag (which this PR intends to keep working), the early logging state (Utils.IsCliOverriding/Utils.CliLogLevel) won’t be set, which can keep CLI logs suppressed in MCP stdio mode despite the user explicitly opting in to logging.
                else if (string.Equals(arg, "--log-level", StringComparison.OrdinalIgnoreCase) && i + 1 < args.Length)
                {
                    Utils.IsCliOverriding = true;
                    if (Enum.TryParse<LogLevel>(args[i + 1], ignoreCase: true, out LogLevel cliLogLevel))
                    {

Comment thread src/Cli/Properties/launchSettings.json Outdated
Comment thread src/Service/Program.cs Outdated
@RubenCerna2079 RubenCerna2079 added this to the June 2026 milestone Jun 8, 2026
@RubenCerna2079 RubenCerna2079 changed the title Dev/rubencerna/fix cli loglevel flag Change CLI flag --LogLevel to --log-level Jun 8, 2026

@souvikghosh04 souvikghosh04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Posting comments so far. rethink if we really need the legacy flag or should error out on unsupported format as we generally do and document these.

Comment thread src/Cli/ConfigGenerator.cs
Comment thread src/Service/Program.cs
Comment on lines +241 to +243
int logLevelIndex = Array.FindIndex(args, a =>
string.Equals(a, "--log-level", StringComparison.OrdinalIgnoreCase) ||
string.Equals(a, "--LogLevel", StringComparison.OrdinalIgnoreCase));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The deprecation warning only fires through the dab start's ConfigGenerator path. When the service host is invoked directly (e.g., dotnet Azure.DataApiBuilder.Service.dll --LogLevel Information, which is what containers and Aspire scenarios do), the legacy flag works but the user is never told it's deprecated. Either emit the same warning here, or document explicitly that the service host will keep both spellings indefinitely. Additionally, I also have commented about do we really need to handle deprecated scenario since the unsupported format ideally should error out and document in new release.

public LogBuffer CliBuffer { get; }

public StartOptions(bool verbose, LogLevel? logLevel, bool isHttpsRedirectionDisabled, bool mcpStdio, string? mcpRole, string config)
public StartOptions(bool verbose, LogLevel? logLevel, LogLevel? logLevelLegacy, bool isHttpsRedirectionDisabled, bool mcpStdio, string? mcpRole, string config)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

New parameters should be added at the end to avoid any existing callers breaking the sequenece of intended params passed in earlier format.

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

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants