diff --git a/src/azure-cli-core/azure/cli/core/__init__.py b/src/azure-cli-core/azure/cli/core/__init__.py index 68cf47589ce..12e9f69eb4e 100644 --- a/src/azure-cli-core/azure/cli/core/__init__.py +++ b/src/azure-cli-core/azure/cli/core/__init__.py @@ -80,6 +80,8 @@ def __init__(self, **kwargs): self.progress_controller = None + _configure_knack() + def refresh_request_id(self): """Assign a new random GUID as x-ms-client-request-id @@ -851,3 +853,19 @@ def get_default_cli(): logging_cls=AzCliLogging, output_cls=AzOutputProducer, help_cls=AzCliHelp) + + +def _configure_knack(): + """Override consts defined in knack to make them Azure CLI-specific.""" + + # Customize status tag messages. + from knack.util import status_tag_messages + ref_message = "Reference and support levels: https://aka.ms/CLI_refstatus" + # Override the preview message. + status_tag_messages['preview'] = "{} is in preview and under development. " + ref_message + # Override the experimental message. + status_tag_messages['experimental'] = "{} is experimental and under development. " + ref_message + + # Allow logs from 'azure' logger to be displayed. + from knack.log import cli_logger_names + cli_logger_names.append("azure") diff --git a/src/azure-cli-core/azure/cli/core/azlogging.py b/src/azure-cli-core/azure/cli/core/azlogging.py index ef060827234..d2c3fbf1064 100644 --- a/src/azure-cli-core/azure/cli/core/azlogging.py +++ b/src/azure-cli-core/azure/cli/core/azlogging.py @@ -49,6 +49,15 @@ def __init__(self, name, cli_ctx=None): self.cli_ctx.register_event(EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE, AzCliLogging.init_command_file_logging) self.cli_ctx.register_event(EVENT_CLI_POST_EXECUTE, AzCliLogging.deinit_cmd_metadata_logging) + def configure(self, args): + super(AzCliLogging, self).configure(args) + from knack.log import CliLogLevel + if self.log_level == CliLogLevel.DEBUG: + # As azure.core.pipeline.policies.http_logging_policy is a redacted version of + # azure.core.pipeline.policies._universal, disable azure.core.pipeline.policies.http_logging_policy + # when debug log is shown. + logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.CRITICAL) + def get_command_log_dir(self): return self.command_log_dir diff --git a/src/azure-cli-core/azure/cli/core/commands/__init__.py b/src/azure-cli-core/azure/cli/core/commands/__init__.py index da1e8293e8c..d959269b633 100644 --- a/src/azure-cli-core/azure/cli/core/commands/__init__.py +++ b/src/azure-cli-core/azure/cli/core/commands/__init__.py @@ -758,7 +758,7 @@ def _resolve_preview_and_deprecation_warnings(self, cmd, parsed_args): deprecate_kwargs['object_type'] = 'command' del deprecate_kwargs['_get_tag'] del deprecate_kwargs['_get_message'] - deprecations.append(ImplicitDeprecated(**deprecate_kwargs)) + deprecations.append(ImplicitDeprecated(cli_ctx=self.cli_ctx, **deprecate_kwargs)) previews = [] + getattr(parsed_args, '_argument_previews', []) if cmd.preview_info: @@ -776,7 +776,7 @@ def _resolve_preview_and_deprecation_warnings(self, cmd, parsed_args): preview_kwargs['object_type'] = 'command' del preview_kwargs['_get_tag'] del preview_kwargs['_get_message'] - previews.append(ImplicitPreviewItem(**preview_kwargs)) + previews.append(ImplicitPreviewItem(cli_ctx=self.cli_ctx, **preview_kwargs)) experimentals = [] + getattr(parsed_args, '_argument_experimentals', []) if cmd.experimental_info: @@ -794,7 +794,7 @@ def _resolve_preview_and_deprecation_warnings(self, cmd, parsed_args): experimental_kwargs['object_type'] = 'command' del experimental_kwargs['_get_tag'] del experimental_kwargs['_get_message'] - experimentals.append(ImplicitExperimentalItem(**experimental_kwargs)) + experimentals.append(ImplicitExperimentalItem(cli_ctx=self.cli_ctx, **experimental_kwargs)) if not self.cli_ctx.only_show_errors: for d in deprecations: diff --git a/src/azure-cli-core/azure/cli/core/commands/client_factory.py b/src/azure-cli-core/azure/cli/core/commands/client_factory.py index ec9bd349743..da219a9ce7d 100644 --- a/src/azure-cli-core/azure/cli/core/commands/client_factory.py +++ b/src/azure-cli-core/azure/cli/core/commands/client_factory.py @@ -127,8 +127,8 @@ def _prepare_client_kwargs_track2(cli_ctx): client_kwargs['logging_enable'] = True # Disable ARMHttpLoggingPolicy which logs only allowed headers - from azure.core.pipeline.policies import SansIOHTTPPolicy - client_kwargs['http_logging_policy'] = SansIOHTTPPolicy() + # from azure.core.pipeline.policies import SansIOHTTPPolicy + # client_kwargs['http_logging_policy'] = SansIOHTTPPolicy() # Prepare User-Agent header, used by UserAgentPolicy client_kwargs['user_agent'] = get_az_user_agent() diff --git a/src/azure-cli-core/setup.py b/src/azure-cli-core/setup.py index 5e1f56ef1c1..c99d1c476da 100644 --- a/src/azure-cli-core/setup.py +++ b/src/azure-cli-core/setup.py @@ -49,7 +49,7 @@ 'colorama~=0.4.1', 'humanfriendly>=4.7,<9.0', 'jmespath', - 'knack==0.7.2', + 'knack==0.8.0rc2', 'msal~=1.0.0', 'msal-extensions~=0.1.3', 'msrestazure>=0.6.3', diff --git a/src/azure-cli/requirements.py3.Darwin.txt b/src/azure-cli/requirements.py3.Darwin.txt index 77740eebcb0..42e779ea2fa 100644 --- a/src/azure-cli/requirements.py3.Darwin.txt +++ b/src/azure-cli/requirements.py3.Darwin.txt @@ -103,7 +103,7 @@ isodate==0.6.0 Jinja2==2.10.1 jmespath==0.9.5 jsmin==2.2.2 -knack==0.7.2 +knack==0.8.0rc2 MarkupSafe==1.1.1 mock==4.0.2 msrest==0.6.18 diff --git a/src/azure-cli/requirements.py3.Linux.txt b/src/azure-cli/requirements.py3.Linux.txt index 77740eebcb0..42e779ea2fa 100644 --- a/src/azure-cli/requirements.py3.Linux.txt +++ b/src/azure-cli/requirements.py3.Linux.txt @@ -103,7 +103,7 @@ isodate==0.6.0 Jinja2==2.10.1 jmespath==0.9.5 jsmin==2.2.2 -knack==0.7.2 +knack==0.8.0rc2 MarkupSafe==1.1.1 mock==4.0.2 msrest==0.6.18 diff --git a/src/azure-cli/requirements.py3.windows.txt b/src/azure-cli/requirements.py3.windows.txt index aee2b82cb28..18074b8cd2e 100644 --- a/src/azure-cli/requirements.py3.windows.txt +++ b/src/azure-cli/requirements.py3.windows.txt @@ -102,7 +102,7 @@ isodate==0.6.0 Jinja2==2.10.1 jmespath==0.9.5 jsmin==2.2.2 -knack==0.7.2 +knack==0.8.0rc2 MarkupSafe==1.1.1 mock==4.0.2 msrest==0.6.18