Skip to content

Commit

Permalink
increase verbosity for jira syncer (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankilevitch authored Jun 9, 2024
1 parent 978fbb8 commit 22e627b
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Settings(BaseSettings):
filter_rule: Union[FilterRule, str, None] = Field(default=None)
operation_kind: OperationKind = OperationKind.scorecard_reminder
target_kind: TargetKind = TargetKind.slack
log_level: str = "INFO"

class Config:
env_prefix = "INPUT_"
Expand Down
1 change: 0 additions & 1 deletion core/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from config import settings
from port.client import PortClient

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion core/github_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from generators.github import GithubIssueGenerator
from targets.github import Github

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down
6 changes: 3 additions & 3 deletions core/jira_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from generators.jira import JiraIssueGenerator
from targets.jira import Jira

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -86,9 +85,10 @@ def ticket_handler(self):
elif not rule_successful and subtask["fields"]["resolution"]:
Jira().reopen_issue(subtask)
elif not rule_successful:
logger.debug(
f"Creating subtask for {rule.get('title')} in {parent_key} for {entity.get('name')}")
Jira().create_issue(generated_subtask)

if (scorecard_level_completed and
task_exists and
not task["fields"]["resolution"]):
task_exists and not task["fields"]["resolution"]):
Jira().resolve_issue(task)
1 change: 0 additions & 1 deletion core/slack_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from generators.slack import SlackMessageGenerator
from targets.slack import Slack

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down
17 changes: 14 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict, Type
import logging

from config import settings
from core.base_handler import BaseHandler
Expand All @@ -7,11 +8,21 @@
from core.slack_handler import SlackHandler

HANDLERS: Dict[str, Type[BaseHandler]] = {
"jira": JiraHandler,
"slack": SlackHandler,
"github": GithubHandler
"jira": JiraHandler,
"slack": SlackHandler,
"github": GithubHandler
}

if len(logging.getLogger().handlers) > 0:
# The Lambda environment pre-configures a handler logging to stderr.
# If a handler is already configured, `.basicConfig` does not execute.
# Thus we set the level directly.
# https://stackoverflow.com/a/56579088
logging.getLogger().setLevel(settings.log_level)
else:
logging.basicConfig(level=settings.log_level)
logger = logging.getLogger(__name__)

if __name__ == '__main__':
operation_kind = settings.operation_kind
handler = HANDLERS.get(settings.target_kind, SlackHandler)()
Expand Down
1 change: 0 additions & 1 deletion targets/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import requests
from config import settings

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

REQUESTS_BACKOFF_FACTOR = 60
Expand Down
3 changes: 1 addition & 2 deletions targets/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from config import settings

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand All @@ -30,7 +29,7 @@ def __init__(self) -> None:

def create_issue(self, params: dict[str, Any]) -> dict[str, Any]:
logger.info(f"Creating new issue: {params['fields']['summary']}")

logger.debug(f"Creating new issue with params: {params}")
create_issue_response = requests.request(
"POST", f"{self.api_url}/issue", json=params, headers=self.headers
)
Expand Down
1 change: 0 additions & 1 deletion targets/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from config import settings

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down

0 comments on commit 22e627b

Please sign in to comment.