Skip to content

Commit 96e510e

Browse files
committed
Reduce error messages on command failure
We are currently seeing some errors logged multiple times. With this patch we remove the cliff log handlers when running commands removing duplicated errors on the console.
1 parent f56c1d9 commit 96e510e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/rhos_ls_mcps/osc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ def __init__(
275275

276276
def configure_logging(self) -> None:
277277
"""Configure logging for the OpenStack shell and cliff app."""
278+
root = logging.getLogger()
279+
handlers_before = list(root.handlers)
278280
super().configure_logging()
281+
# Remove any handlers cliff added to the root logger
282+
for handler in root.handlers:
283+
if handler not in handlers_before:
284+
root.removeHandler(handler)
279285

280286
# We need to change the LOG variable to make sure it uses the right stderr instead of sys.stderr
281287
console = logging.StreamHandler(self.stderr)

0 commit comments

Comments
 (0)