Skip to content

Commit

Permalink
refactor: add logging module
Browse files Browse the repository at this point in the history
  • Loading branch information
miztch committed Oct 7, 2023
1 parent a4ba79e commit c0de522
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
8 changes: 5 additions & 3 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from chalice import Chalice
from chalicelib import database, date_format
from chalicelib import database, date_format, log

logger = log.getLogger()

app = Chalice(app_name="dima")

Expand All @@ -18,7 +20,7 @@ def matches():
return upcoming matches list.
"""
request = app.current_request
app.log.debug("Request: {}".format(request.to_dict()))
logger.debug("Request: {}".format(request.to_dict()))

# default date for search: today
date = date_format.get_default()
Expand All @@ -32,6 +34,6 @@ def matches():
date = param

matches = database.query(date)
app.log.debug("Return {} items.".format(len(matches)))
logger.debug("Return {} items.".format(len(matches)))

return matches
6 changes: 3 additions & 3 deletions api/chalicelib/database.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
import os

import boto3
from boto3.dynamodb.conditions import Key, Attr
from chalicelib import log

logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger = log.getLogger()


def _get_table():
Expand Down
6 changes: 3 additions & 3 deletions api/chalicelib/date_format.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import re
from datetime import datetime

logger = logging.getLogger()
logger.setLevel(logging.INFO)
from chalicelib import log

logger = log.getLogger()


def validate(date):
Expand Down
11 changes: 11 additions & 0 deletions api/chalicelib/log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import logging


def getLogger():
"""
init logger.
"""
logger = logging.getLogger()
logger.setLevel(logging.INFO)

return logger

0 comments on commit c0de522

Please sign in to comment.