Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidated use of rich console #2980

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ install_requires =
click-completion >= 0.5.1
click-help-colors >= 0.6
cookiecutter >= 1.6.0, != 1.7.1
enrich >= 1.2
enrich >= 1.2.1
Jinja2 >= 2.10.1
packaging
paramiko >= 2.5.0, < 3
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import sys
from typing import Any

from enrich.console import Console
from rich.style import Style
from rich.theme import Theme
from subprocess_tee.rich import ConsoleEx

theme = Theme(
{
Expand Down Expand Up @@ -60,6 +60,6 @@ def should_do_markup() -> bool:
return sys.stdout.isatty() and os.environ.get("TERM") != "dumb"


console = ConsoleEx(
console = Console(
force_terminal=should_do_markup(), theme=theme, record=True, redirect=True
)
6 changes: 4 additions & 2 deletions src/molecule/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from enrich.console import Console
from enrich.logging import RichHandler

from molecule.console import console
from molecule.console import console, should_do_markup, theme
from molecule.text import chomp

SUCCESS = 100
Expand Down Expand Up @@ -100,4 +100,6 @@ def get_logger(name=None) -> logging.Logger:
return logger


LOGGING_CONSOLE = Console(file=sys.stderr, force_terminal=True)
LOGGING_CONSOLE = Console(
file=sys.stderr, force_terminal=should_do_markup(), theme=theme
)