Skip to content

Commit

Permalink
Patch awx logging to allow trace logging in all cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapaioa committed Apr 19, 2024
1 parent 93b846d commit 2ce85ee
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions broker/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def redact_dynaconf(self, data):


def patch_awx_for_verbosity(api):
"""Patch the awxkit API to log when we're at trace level."""
client = api.client
awx_log = client.log

"""Patch the awxkit API to enable trace-level logging of API calls to Ansible provider."""
awx_log = api.client.log
awx_log.parent = logzero.logger

def patch(cls, name):
Expand Down Expand Up @@ -120,7 +118,7 @@ def set_file_logging(level=settings.logging.file_level, path="logs/broker.log"):
# settings.logging.file_level. Otherwise, use the value from settings.
old_log_level = resolve_log_level(settings.logging.file_level)
new_log_level = resolve_log_level(level)
log_level = new_log_level if new_log_level.value < old_log_level.value else old_log_level
log_level = new_log_level if new_log_level < old_log_level else old_log_level

path = BROKER_DIRECTORY.joinpath(path)
path.parent.mkdir(parents=True, exist_ok=True)
Expand All @@ -143,10 +141,7 @@ def setup_logzero(
):
"""Call logzero setup with the given settings."""
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# FIXME helpers.update_log_level also needs to do this,
# if "--log-level trace" is passed to the CLI.
if isinstance(level, str) and level.lower() == "trace":
patch_awx_for_verbosity(awxkit.api)
patch_awx_for_verbosity(awxkit.api)
set_log_level(level)
set_file_logging(file_level, path)
if formatter:
Expand Down

0 comments on commit 2ce85ee

Please sign in to comment.