Skip to content

Commit 0c512de

Browse files
committed
cmk-dev-deploy: Log @_verbose_only output to deploy log file
The _verbose_only decorator was a hard no-op at default verbosity, so site info, change summaries, and other decorated output never reached the log file. Now the decorated function always runs but console output is suppressed via a thread-local log_only flag. Change-Id: I07175c6f08c5831ffe4c83ad0a64fe27fd124a35
1 parent f49e4be commit 0c512de

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • packages/cmk-dev-deploy/cmk/dev_deploy/core

packages/cmk-dev-deploy/cmk/dev_deploy/core/output.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,22 @@ def _deploy_prefix() -> str:
169169

170170

171171
def _verbose_only[**P](fn: Callable[P, None]) -> Callable[P, None]:
172-
"""Decorator that makes a function no-op when verbosity < VERBOSE."""
172+
"""Decorator that suppresses console output when verbosity < VERBOSE.
173+
174+
The decorated function still runs at default verbosity so that all
175+
output is captured in the log file — only terminal printing is skipped.
176+
"""
173177

174178
@functools.wraps(fn)
175179
def wrapper(*args: P.args, **kwargs: P.kwargs) -> None:
176180
if _config.verbosity >= Verbosity.VERBOSE:
177181
fn(*args, **kwargs)
182+
else:
183+
_config.thread_local.log_only = True
184+
try:
185+
fn(*args, **kwargs)
186+
finally:
187+
_config.thread_local.log_only = False
178188

179189
return wrapper
180190

@@ -217,6 +227,8 @@ def _tty_print(msg: str, *, file: Any = None) -> None:
217227

218228
def _print_locked(msg: str, *, file: Any = None) -> None:
219229
_log_to_file(msg)
230+
if getattr(_config.thread_local, "log_only", False):
231+
return
220232
if getattr(_config.thread_local, "buffering", False):
221233
_config.thread_local.buffer.append((msg, file))
222234
return

0 commit comments

Comments
 (0)