display: fix log verbosity (#83179) (#83191)

* display, ensure we have a logger before we log

(cherry picked from commit 2816922cd6)
pull/83231/head
Brian Coca 7 months ago committed by GitHub
parent 9c14a7a3e4
commit 7b9aa6ca0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- ensure we have logger before we log when we have increased verbosity.

@ -451,7 +451,7 @@ class Display(metaclass=Singleton):
def _log(self, msg: str, color: str | None = None, caplevel: int | None = None):
if caplevel is None or self.log_verbosity > caplevel:
if logger and (caplevel is None or self.log_verbosity > caplevel):
msg2 = msg.lstrip('\n')
lvl = logging.INFO
@ -462,6 +462,7 @@ class Display(metaclass=Singleton):
except KeyError:
# this should not happen, but JIC
raise AnsibleAssertionError('Invalid color supplied to display: %s' % color)
# actually log
logger.log(lvl, msg2)

@ -21,3 +21,6 @@ if [ "$rc" == "0" ]; then
false # fail if we found EXEC in stdout
fi
grep -q EXEC "${ALOG}"
# Test that setting verbosity with no log won't crash
ANSIBLE_LOG_VERBOSITY=2 ansible-playbook logit.yml

Loading…
Cancel
Save