Skip to content
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

[Log] Print INFO log from SDK #221

Merged
merged 8 commits into from
Dec 17, 2020
Merged

[Log] Print INFO log from SDK #221

merged 8 commits into from
Dec 17, 2020

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Oct 27, 2020

  1. Previously in get_logger, logger name is the module name prefixed with CLI_LOGGER_NAME, like cli.azure.cli.core. Now it only takes the module name, like azure.cli.core, to be in sync with the Python SDK's logger name azure.*.

  2. Make cli_logger_name customizable, so that all INFO logs under azure.* loggers can be printed, like

    • azure.core.pipeline.policies.http_logging_policy
    • azure.cli.core
  3. Previously, logger cli.azure.cli.core's logger name is not printed:

    Modules found from index for 'group': ['azure.cli.command_modules.resource']
    Loading command modules:
    Name                  Load Time    Groups  Commands
    resource                  0.009        35       164
    Total (1)                 0.009        35       164
    

    Now the logger name is printed even for CLI logger when --debug is specified, so that the log source can be better distinguished.

ℹ As before, DEBUG log from both CLI and underlying libs will be printed, so this won't affect DEBUG log.

Example:

> az group show -n fy --debug
DEBUG: knack.log: File logging enabled - writing logs to 'C:\Users\jiasli\.azure\logs'.
DEBUG: knack.cli: Command arguments: ['group', 'show', '-n', 'fy', '--debug']
DEBUG: knack.cli: Event: Cli.PreExecute []
...
DEBUG: azure.cli.core: Modules found from index for 'group': ['azure.cli.command_modules.resource']
DEBUG: azure.cli.core: Loading command modules:
DEBUG: azure.cli.core: Name                  Load Time    Groups  Commands
DEBUG: azure.cli.core: resource                  0.009        35       164
DEBUG: azure.cli.core: Total (1)                 0.009        35       164
...
DEBUG: azure.cli.core._profile: Retrieving token from ADAL for resource 'https://management.core.windows.net/'
...
DEBUG: azure.core.pipeline.policies._universal: Request URL: 'https://management.azure.com/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/fy?api-version=2020-06-01'
DEBUG: azure.core.pipeline.policies._universal: Request method: 'GET'
DEBUG: azure.core.pipeline.policies._universal: Request headers:
DEBUG: azure.core.pipeline.policies._universal:     'Accept': 'application/json'
...
INFO: azure.core.pipeline.policies.http_logging_policy: Request URL: 'https://management.azure.com/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/fy?api-version=REDACTED'
INFO: azure.core.pipeline.policies.http_logging_policy: Request method: 'GET'
INFO: azure.core.pipeline.policies.http_logging_policy: Request headers:
INFO: azure.core.pipeline.policies.http_logging_policy:     'Accept': 'application/json'
INFO: azure.core.pipeline.policies.http_logging_policy:     'x-ms-client-request-id': 'd8fa889e-1822-11eb-b2f8-84a93e63aa78'
...

> az group show -n fy --verbose
...
INFO: azure.core.pipeline.policies.http_logging_policy: Request URL: 'https://management.azure.com/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/fy?api-version=REDACTED'
INFO: azure.core.pipeline.policies.http_logging_policy: Request method: 'GET'
INFO: azure.core.pipeline.policies.http_logging_policy: Request headers:
INFO: azure.core.pipeline.policies.http_logging_policy:     'Accept': 'application/json'
INFO: azure.core.pipeline.policies.http_logging_policy:     'x-ms-client-request-id': 'd8fa889e-1822-11eb-b2f8-84a93e63aa78'
...

@haroldrandom
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 16, 2020

Log

@jiasli jiasli self-assigned this Dec 9, 2020
@jiasli jiasli requested review from Juliehzl and removed request for arrownj December 16, 2020 08:43
@jiasli jiasli merged commit 6ec54e0 into microsoft:master Dec 17, 2020
@jiasli jiasli deleted the info-log branch December 17, 2020 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants