feat: 外のモジュール、同階層に無いとだめっぽい.まだ動かない

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2022-07-01 14:57:43 +09:00
parent f5d6e6b525
commit 77ad303506
7 changed files with 17 additions and 19 deletions

View File

@ -8,8 +8,7 @@ COPY Pipfile Pipfile.lock ${WORKDIR}
RUN pip install pipenv --no-cache-dir && \
pipenv install --system --deploy && \
pip uninstall -y pipenv virtualenv-clone virtualenv
COPY ./src $WORKDIRsrc
COPY main.py $WORKDIR
COPY check-view-option ./
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD [ "main.handler" ]

View File

@ -5,3 +5,7 @@ class MeDaCaException(Exception, metaclass=ABCMeta):
def __init__(self, error_id: str, message) -> None:
super().__init__(message)
self.error_id = error_id
class FileNotFoundException(MeDaCaException):
pass

View File

@ -2,9 +2,8 @@
Viewセキュリティオプション付与チェック用Lambda関数のエントリーポイント
"""
from src.error.file_not_found_exception import FileNotFoundException
from src.error.madaca_exception import MeDaCaException
from src.logger.logger import MeDaCaLogger
from exceptions import FileNotFoundException, MeDaCaException
from medaca_logger import MeDaCaLogger
def handler(event, context):
@ -12,8 +11,9 @@ def handler(event, context):
try:
logger.info('lambda handle')
raise FileNotFoundException('E-02-01', 'ファイル見つかりません')
except MeDaCaException as e:
logger.exception(f'exception: {e.error_id} {e}')
except Exception as e:
logger.exception(f'exception: {e}')
# logger.exception(f'exception: {e.error_id} {e}')
# ローカル実行用

View File

@ -2,9 +2,8 @@ import datetime
import logging
from zoneinfo import ZoneInfo
from ..system_vars.constants import (DEFAULT_TIMEZONE, LOG_DATE_FORMAT,
LOG_FORMAT)
from ..system_vars.environments import LOG_LEVEL
from constants import DEFAULT_TIMEZONE, LOG_DATE_FORMAT, LOG_FORMAT
from environments import LOG_LEVEL
class SingletonLogger:
@ -12,16 +11,17 @@ class SingletonLogger:
@staticmethod
def __internal_new__() -> logging.Logger:
# logger設定
logger = logging.getLogger()
formatter = logging.Formatter(
LOG_FORMAT,
LOG_DATE_FORMAT
)
formatter.converter = lambda: datetime.datetime.now(ZoneInfo(DEFAULT_TIMEZONE)).timetuple()
for handler in logger.handlers:
handler.setFormatter(formatter)
level = logging.getLevelName(LOG_LEVEL)
logging.basicConfig(level=level, format=LOG_FORMAT, datefmt=LOG_DATE_FORMAT)
# logger.setLevel(level)
logger = logging.getLogger()
print(level)
logger.setLevel(level)
return logger

View File

@ -1,5 +0,0 @@
from .madaca_exception import MeDaCaException
class FileNotFoundException(MeDaCaException):
pass