Skip to content

webapp log tail throws TypeError #17987

@npazosmendez

Description

@npazosmendez

Describe the bug

The appservice module throws TypeError when trying to stream logs.

[ ~ ]$ az webapp log tail --name mywebapp --resource-group myresourcegroup
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/nicolas/pyenvs/az/lib/python3.7/site-packages/azure/cli/command_modules/appservice/custom.py", line 2345, in _get_log
    .decode(std_encoding, errors='replace'), end='')  # each line of log has CRLF.
  File "/usr/lib/python3.7/logging/__init__.py", line 1390, in warning
    self._log(WARNING, msg, args, **kwargs)
TypeError: _log() got an unexpected keyword argument 'end'

As the error says, end is not a valid keyword for _log() (internal for logging.warning). It is a valid keyword for print though, which was being used before this change 680f833#diff-76cc90184fe3a5df817ac304d5929231658bef52748a4560dabf51ee18bf8f02L2362:

-                print(chunk.decode(encoding='utf-8', errors='replace')
-                      .encode(std_encoding, errors='replace')
-                      .decode(std_encoding, errors='replace'), end='')  # each line of log has CRLF.
+                logger.warning(chunk.decode(encoding='utf-8', errors='replace')
+                               .encode(std_encoding, errors='replace')
+                               .decode(std_encoding, errors='replace'), end='')  # each line of log has CRLF.

To Reproduce

  • Create an App Service through Azure Portal
  • Login using az login
  • Run az webapp log tail --name $WEBAPP --resource-group $RESGROUP pointing to the app service previosuly created.

Expected behavior

The command should stream logs and not fail.

Environment summary

  • Install Method: pip
  • Python version: Python 3.7.10 (I also tried 3.8 and 3.9)
  • OS: Manjaro Linux
  • Shell Type: bash
  • CLI version:
[~]$ az --version
azure-cli                         2.23.0

core                              2.23.0
telemetry                          1.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Service AttentionThis issue is responsible by Azure service team.Web Appsaz webappquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions