Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.98k forks source link

Improve ACI log handling when output is piped #17037

Open NoNameProvided opened 3 years ago

NoNameProvided commented 3 years ago

We have a container which output logs via pino. When the output is not formatted the terminal will continuously blink as I assume the CLI compares the requested log to the currently printed one and updates the terminal with the latest lines.

However when we pipe the output of the command to pino-pretty which formats the log statement to human readable format, the CLI will continuously print the same lines over and over again in every refresh cycle. (As I assume it cannot find a match between the received value and what is printed in the terminal.

Actual behavior

Let's say we have a container what prints one and only one line of message. When running the following command:

az container attach --resource-group rg-my-resource-group --name aci-my-container

The terminal will display that line once, but the terminal will keep blinking as the content is updated. However when running the following command:

az container attach --resource-group rg-my-resource-group --name aci-my-container | pino-pretty --colorize

The output from the container will be printed over and over again for every refresh cycle.

Expected behavior

I would expect that the Azure CLI keeps an internal buffer of received messages, calculates the difference internally and only prints to the console when a new line is received.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

Issue Details
We have a container which output logs via pino. When the output is not formatted the terminal will continuously blink as I assume the CLI compares the requested log to the currently printed one and updates the terminal with the latest lines. However when we pipe the output of the command to `pino-pretty` which formats the log statement to human readable format, the CLI will continuously print the same lines over and over again in every refresh cycle. (As I assume it cannot find a match between the received value and what is printed in the terminal. ### Actual behavior Let's say we have a container what prints one and only one line of message. When running the following command: ``` az container attach --resource-group rg-my-resource-group --name aci-my-container ``` The terminal will display that line once, but the terminal will keep blinking as the content is updated. However when running the following command: ``` az container attach --resource-group rg-my-resource-group --name aci-my-container | pino-pretty --colorize ``` The output from the container will be printed over and over again for every refresh cycle. ### Expected behavior I would expect that the Azure CLI keeps an internal buffer of received messages, calculates the difference internally and only prints to the console when a new line is received. --- #### Document Details ⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.* * ID: 2e5d1da7-7c4f-c9e6-e4b9-a30407675acf * Version Independent ID: ba32e12d-8283-f980-e1d0-1ca2a75a5152 * Content: [az container](https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az_container_attach) * Content Source: [latest/docs-ref-autogen/container.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/latest/docs-ref-autogen/container.yml) * Service: **container-service** * GitHub Login: @rloutlaw * Microsoft Alias: **routlaw**
Author: NoNameProvided
Assignees: -
Labels: `Container Instances`, `Service Attention`, `needs-triage`, `question`
Milestone: -
yonzhan commented 3 years ago

container

rayoef commented 1 year ago

reassign:tomvcassidy

rayoef commented 1 year ago

label: "container-instances"