Azure / Azure/azure-cli

Improve ACI log handling when output is piped

Open
#17,037 4 comments 0 reactions 0 assignees View on GitHub
act-observability-squad Container Instances Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

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**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.