Skip to content

Commit

Permalink
fix: Fix progressbar issue (#165)
Browse files Browse the repository at this point in the history
* fix: Avoid tqdm progress bar interruption

Avoid tqdm progress bar interruption by logger's output to console

* doc: Update CHANGELOG.md
  • Loading branch information
mkb79 authored Nov 15, 2023
1 parent 72b4ff9 commit cda40c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Update marketplace choices in `manage auth-file add` command. Now all available marketplaces are listed.

### Bugfix

- Avoid tqdm progress bar interruption by logger’s output to console.

### Misc

- add `freeze_support` to pyinstaller entry script (#78)
Expand Down
12 changes: 8 additions & 4 deletions src/audible_cli/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from warnings import warn

import click
from tqdm import tqdm


audible_cli_logger = logging.getLogger("audible_cli")
Expand Down Expand Up @@ -100,10 +101,13 @@ def emit(self, record):
try:
msg = self.format(record)
level = record.levelname.lower()
if self.echo_kwargs.get(level):
click.echo(msg, **self.echo_kwargs[level])
else:
click.echo(msg)

# Avoid tqdm progress bar interruption by logger's output to console
with tqdm.external_write_mode():
if self.echo_kwargs.get(level):
click.echo(msg, **self.echo_kwargs[level])
else:
click.echo(msg)
except Exception:
self.handleError(record)

Expand Down

0 comments on commit cda40c6

Please sign in to comment.