summaryrefslogtreecommitdiff
path: root/robusta_krr/utils
diff options
context:
space:
mode:
authorПавел Жуков <33721692+LeaveMyYard@users.noreply.github.com>2023-04-24 11:09:01 +0300
committerПавел Жуков <33721692+LeaveMyYard@users.noreply.github.com>2023-04-24 11:09:01 +0300
commitb54c2ef892a4964a329db3326fe1a80281b73d43 (patch)
tree38dcdd58dc2e04210f1beb8b2a6efbfe649829a5 /robusta_krr/utils
parentc63661a6c784971da1831c65d66f33e325d2115a (diff)
Add --logtostderr flag
Diffstat (limited to 'robusta_krr/utils')
-rw-r--r--robusta_krr/utils/configurable.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/robusta_krr/utils/configurable.py b/robusta_krr/utils/configurable.py
index 3957e6e..ded2900 100644
--- a/robusta_krr/utils/configurable.py
+++ b/robusta_krr/utils/configurable.py
@@ -6,8 +6,6 @@ from rich.console import Console
from robusta_krr.core.models.config import Config
-console = Console()
-
class Configurable(abc.ABC):
"""
@@ -17,7 +15,7 @@ class Configurable(abc.ABC):
def __init__(self, config: Config) -> None:
self.config = config
- self.console = console
+ self.console = Console(stderr=self.config.log_to_stderr)
@property
def debug_active(self) -> bool:
@@ -31,6 +29,13 @@ class Configurable(abc.ABC):
def __add_prefix(text: str, prefix: str, /, no_prefix: bool) -> str:
return f"{prefix} {text}" if not no_prefix else text
+ def print_result(self, content: str) -> None:
+ """
+ Prints the result in a console. The result is always put in stdout.
+ """
+ result_console = Console()
+ result_console.print(content)
+
def echo(
self, message: str = "", *, no_prefix: bool = False, type: Literal["INFO", "WARNING", "ERROR"] = "INFO"
) -> None: