diff --git a/httpie/context.py b/httpie/context.py index 2a54f46916..c7567d1922 100644 --- a/httpie/context.py +++ b/httpie/context.py @@ -36,6 +36,7 @@ class LogLevel(str, Enum): LogLevel.ERROR: GenericColor.RED, } + LOG_LEVEL_DISPLAY_THRESHOLDS = { LogLevel.INFO: 1, LogLevel.WARNING: 2, @@ -168,7 +169,9 @@ def as_silent(self) -> Iterator[None]: self.stderr = original_stderr def log_error(self, msg: str, level: LogLevel = LogLevel.ERROR) -> None: - if self.stdout_isatty and self.quiet >= LOG_LEVEL_DISPLAY_THRESHOLDS[level]: + # FIXED: Removed self.stdout_isatty from condition + # This ensures that the quiet flag works correctly even when stdout is redirected + if self.quiet >= LOG_LEVEL_DISPLAY_THRESHOLDS[level]: stderr = self.stderr # Not directly /dev/null, since stderr might be mocked else: stderr = self._orig_stderr @@ -214,4 +217,4 @@ def rich_console(self): @cached_property def rich_error_console(self): - return self._make_rich_console(self.stderr, self.stderr_isatty) + return self._make_rich_console(self.stderr, self.stderr_isatty) \ No newline at end of file