az container logs --follow repeats log lines over instead of outputting only new lines
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
`az container logs --follow` repeats log lines it has already output multiple times while tailing container logs.
**To Reproduce**
Run `az container logs --follow` on a simple container that logs a new line every 10 seconds.
You will see the earlier lines repeated in the stdout of `az container logs --follow` each time it polls, like:
```
$ az container logs --ids $container_id --follow
line1
line2
line1
line2
line3
line1
line2
line3
line4
```
where each time it polls, it prints the last 'n' lines to stdout, whether or not it printed them already in a prior poll.
**Expected behavior**
Behave like `tail -f -n +1` i.e. output all available log lines, then *only output new log lines generated since the last output was written* while polling. So if you `az container logs --tail` a container that is logging a line every 10 seconds you should see:
```
$ az container logs --ids $container_id --tail
line1
line2
line3
line4
```
with each line appearing a few seconds after the container writes it to the log.
**Environment summary**
```
Linux-5.16.5-200.fc35.x86_64-x86_64-with-glibc2.34, Fedora Linux 35 (Workstation Edition)
Python 3.10.2
Installer: PIP
azure-cli 2.32.0 *
Extensions:
log-analytics 0.2.2
storage-blob-preview 0.6.1
account 0.2.1
resource-graph 2.1.0
storage-preview 0.8.0
Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0
```
**Additional context**
It'd help to update the help output to mention that this prints the last 'n' lines in full each poll cycle, not the *new* lines.
Contributor guide
Assessment
This issue has not been assessed yet.