Skip to content

Commit

Permalink
Only print traceback when debug is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jo1gi committed Nov 29, 2023
1 parent b6af29d commit d4fe47d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions audiobookdl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import sys
from rich.prompt import Prompt
from typing import List, Optional, Union
import traceback


def main() -> None:
Expand All @@ -32,7 +31,8 @@ def main() -> None:
process_url(url, options, config)
except AudiobookDLException as e:
e.print()
traceback.print_exc()
if logging.debug_mode:
logging.print_traceback()
exit(1)


Expand Down
7 changes: 7 additions & 0 deletions audiobookdl/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rich.progress import Progress, ProgressColumn
from typing import Union, List
from audiobookdl.utils import read_asset_file
import traceback

debug_mode = False
quiet_mode = False
Expand Down Expand Up @@ -62,3 +63,9 @@ def simple_help() -> None:

def progress(progress_format: List[Union[str, ProgressColumn]]) -> Progress:
return Progress(*progress_format, console=console)

def print_traceback() -> None:
"""Print traceback"""
console.print()
console.print("[underline white bold]Traceback[/]")
traceback.print_exc()

0 comments on commit d4fe47d

Please sign in to comment.