Skip to content

Commit

Permalink
chore: updates logger to ensure trestle and bot logs are standardized
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Jul 10, 2023
1 parent 3cde7d3 commit 73a1ba9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions trestlebot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from trestlebot.tasks.base_task import TaskBase, TaskException


logger = logging.getLogger(__name__)
logger = logging.getLogger("trestle")


class RepoException(Exception):
Expand Down Expand Up @@ -161,9 +161,10 @@ def run(
# Only create a pull request if a GitProvider is configured and
# a target branch is set.
if git_provider is not None and target_branch:
logger.info("Git provider detected, submitting pull request")
logger.info("Git provider detected, submitting pull request to {target_branch}")
# Parse remote url to get repository information for pull request
namespace, repo_name = git_provider.parse_repository(remote.url)
logger.debug("Detected namespace {namespace} and {repo_name}")

git_provider.create_pull_request(
ns=namespace,
Expand All @@ -177,11 +178,11 @@ def run(
return commit_sha

except GitCommandError as e:
raise RepoException(f"Git push to {branch} failed: {e}") from e
raise RepoException(f"Git push to {branch} failed: {e}")
except GitProviderException as e:
raise RepoException(
f"Git pull request to {target_branch} failed: {e}"
) from e
)
else:
logger.info("Nothing to commit")
return commit_sha
Expand Down
2 changes: 1 addition & 1 deletion trestlebot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from trestlebot.tasks.regenerate_task import RegenerateTask


logger = logging.getLogger("trestlebot")
logger = logging.getLogger("trestle")


def _parse_cli_arguments() -> argparse.Namespace:
Expand Down
4 changes: 2 additions & 2 deletions trestlebot/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

# Singleton logger instance
# All other CLI sub module will inherit settings of this logger as long as
# sub-module instantiates a logger with a prefix 'trestlebot' or __name__
_logger = logging.getLogger("trestlebot")
# sub-module instantiates a logger with a prefix 'trestle' or __name__
_logger = logging.getLogger("trestle")


class SpecificLevelFilter(logging.Filter):
Expand Down

0 comments on commit 73a1ba9

Please sign in to comment.