Skip to content

Commit 81b5a74

Browse files
Logging (#82)
1 parent 944efa1 commit 81b5a74

5 files changed

Lines changed: 76 additions & 1 deletion

File tree

.github/workflows/build_and_publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
--network=web \
8686
--volume com_profcomff_api_timetable_test_static:/app/static \
8787
--env DB_DSN=${{ secrets.DB_DSN }} \
88+
--env GUNICORN_CMD_ARGS='--log-config logging_test.conf' \
8889
--env GOOGLE_CLIENT_SECRET='${{ secrets.GOOGLE_CLIENT_SECRET }}' \
8990
--env STATIC_PATH=static \
9091
--name ${{ env.CONTAITER_NAME }} \
@@ -131,6 +132,7 @@ jobs:
131132
--env ADMIN_SECRET='${{ secrets.ADMIN_SECRET }}' \
132133
--env REDIRECT_URL='https://www.profcomff.com/timetable/google' \
133134
--env GOOGLE_CLIENT_SECRET='${{ secrets.GOOGLE_CLIENT_SECRET }}' \
135+
--env GUNICORN_CMD_ARGS='--log-config logging_prod.conf' \
134136
--env STATIC_PATH=static \
135137
--name ${{ env.CONTAITER_NAME }} \
136138
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ RUN pip install -U -r /app/requirements.txt
88
COPY ./static /app/static/
99

1010
COPY ./alembic.ini /alembic.ini
11+
COPY ./logging_prod.conf /app/
12+
COPY ./logging_test.conf /app/
1113
COPY ./migrations /migrations/
1214

1315
COPY ./${APP_NAME} /app/${APP_NAME}

logging_prod.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[loggers]
2+
keys=root,gunicorn.error,gunicorn.access
3+
4+
[handlers]
5+
keys=all
6+
7+
[formatters]
8+
keys=json
9+
10+
[logger_root]
11+
level=INFO
12+
handlers=all
13+
14+
[logger_gunicorn.error]
15+
level=INFO
16+
handlers=all
17+
propagate=0
18+
qualname=gunicorn.error
19+
formatter=json
20+
21+
[logger_gunicorn.access]
22+
level=INFO
23+
handlers=all
24+
propagate=0
25+
qualname=gunicorn.access
26+
formatter=json
27+
28+
[handler_all]
29+
class=StreamHandler
30+
formatter=json
31+
level=INFO
32+
args=(sys.stdout,)
33+
34+
[formatter_json]
35+
class=logger.formatter.JSONLogFormatter

logging_test.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[loggers]
2+
keys=root,gunicorn.error,gunicorn.access
3+
4+
[handlers]
5+
keys=all
6+
7+
[formatters]
8+
keys=json
9+
10+
[logger_root]
11+
level=DEBUG
12+
handlers=all
13+
14+
[logger_gunicorn.error]
15+
level=DEBUG
16+
handlers=all
17+
propagate=0
18+
qualname=gunicorn.error
19+
formatter=json
20+
21+
[logger_gunicorn.access]
22+
level=DEBUG
23+
handlers=all
24+
propagate=0
25+
qualname=gunicorn.access
26+
formatter=json
27+
28+
[handler_all]
29+
class=StreamHandler
30+
formatter=json
31+
level=DEBUG
32+
args=(sys.stdout,)
33+
34+
[formatter_json]
35+
class=logger.formatter.JSONLogFormatter

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ SQLAlchemy
1515
gunicorn
1616
python-multipart
1717
httpx
18-
Pillow
18+
Pillow
19+
logging-profcomff

0 commit comments

Comments
 (0)