✨ Support not logging individual calls on CommandlineCaller

This commit is contained in:
Gina Häußge committed 2023-01-23 14:50:38 +01:00
1 parent e335055a98
commit 241ec251a2
1 file changed
+8 -3
+8 -3
View File
@@ -161,6 +161,7 @@ class CommandlineCaller:
command: Union[str, List[str], Tuple[str]],
delimiter: bytes = b"\n",
buffer_size: int = -1,
logged: bool = True,
**kwargs,
) -> Tuple[Optional[int], List[str], List[str]]:
"""
@@ -176,7 +177,7 @@ class CommandlineCaller:
"""
p = self.non_blocking_call(
command, delimiter=delimiter, buffer_size=buffer_size, **kwargs
command, delimiter=delimiter, buffer_size=buffer_size, logged=logged, **kwargs
)
if p is None:
return None, [], []
@@ -190,7 +191,8 @@ class CommandlineCaller:
processed = self._preprocess_lines(
*map(lambda x: to_unicode(x, errors="replace"), lines)
)
logger(*processed)
if logged:
logger(*processed)
return list(processed)
def process_stdout(lines):
@@ -218,6 +220,7 @@ class CommandlineCaller:
command: Union[str, List, Tuple],
delimiter: bytes = b"\n",
buffer_size: int = -1,
logged: bool = True,
**kwargs,
) -> Optional[sarge.Pipeline]:
if isinstance(command, (list, tuple)):
@@ -225,7 +228,9 @@ class CommandlineCaller:
else:
joined_command = command
self._logger.debug(f"Calling: {joined_command}")
self.on_log_call(joined_command)
if logged:
self.on_log_call(joined_command)
kwargs.update(
{