-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
30 lines (26 loc) · 1.01 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from typing import Dict, Type
import logging
from config import settings
from core.base_handler import BaseHandler
from core.jira_handler import JiraHandler
from core.github_handler import GithubHandler
from core.slack_handler import SlackHandler
HANDLERS: Dict[str, Type[BaseHandler]] = {
"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)()
operation_kind_handler = getattr(handler, settings.operation_kind)
operation_kind_handler()