Skip to content

Commit

Permalink
feat: log information about config status on start
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Jan 27, 2025
1 parent 4bc83ab commit 1f39c0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pydisgit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
app.config.from_object(Config)
app.config.from_prefixed_env(prefix="PYDISGIT")

bound = BoundEnv(app.config)
bound = BoundEnv(app.config, app.logger)

from .handlers import router as free_handler_router
handler_router = free_handler_router.bind(bound, app.logger)
Expand Down
8 changes: 7 additions & 1 deletion src/pydisgit/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Configuration for pydisgit
"""
from typing import Optional
import logging
import re

class Config:
Expand Down Expand Up @@ -30,14 +31,19 @@ class BoundEnv:
__pastegg_api_key: str
__github_webhook_secret: str;

def __init__(self, env):
def __init__(self, env, logger):
self.__ignored_branch_pattern = re.compile(env['IGNORED_BRANCH_REGEX']) if 'IGNORED_BRANCH_REGEX' in env else None
self.__ignored_branches = env['IGNORED_BRANCHES'].split(",")
self.__ignored_users = env['IGNORED_USERS'].split(",")
self.__ignored_payloads = env['IGNORED_PAYLOADS'].split(",")
self.__pastegg_api_key = env['PASTE_GG_API_KEY']
self.__github_webhook_secret = env['GITHUB_WEBHOOK_SECRET']

logger.info("Ignored branch pattern: %s", self.__ignored_branch_pattern)
logger.info("Ignored branches: %s", self.__ignored_branches)
logger.info("Ignored users: %s", self.__ignored_users)
logger.info("Ignored payloads: %s", self.__ignored_payloads)

def ignored_branch(self, branch: str) -> bool:
return (self.__ignored_branch_pattern
and self.__ignored_branch_pattern.match(branch)) \
Expand Down

0 comments on commit 1f39c0c

Please sign in to comment.