Skip to content

Commit a243fb0

Browse files
authored
feat: add logging config (#16)
1 parent e555d27 commit a243fb0

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ENV PATH="/home/${NB_USER}/.local/bin:${PATH}"
3939
ENV LD_LIBRARY_PATH=/usr/local/lib
4040
ENV LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
4141

42+
COPY logger_config.yaml logger_config.yaml
4243
COPY requirements/dev.txt requirements-dev.txt
4344
COPY requirements/base.txt requirements-base.txt
4445
COPY prepline_${PIPELINE_PACKAGE}/ prepline_${PIPELINE_PACKAGE}/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ docker-build:
7171

7272
.PHONY: docker-start-api
7373
docker-start-api:
74-
docker run -p 8000:8000 --mount type=bind,source=$(realpath .),target=/home/notebook-user/local -t --rm pipeline-family-${PIPELINE_FAMILY}-dev:latest uvicorn ${PACKAGE_NAME}.api.app:app --host 0.0.0.0 --port 8000
74+
docker run -p 8000:8000 --mount type=bind,source=$(realpath .),target=/home/notebook-user/local -t --rm pipeline-family-${PIPELINE_FAMILY}-dev:latest uvicorn ${PACKAGE_NAME}.api.app:app --log-config logger_config.yaml --host 0.0.0.0 --port 8000
7575

7676
.PHONY: docker-start-jupyter
7777
docker-start-jupyter:
@@ -90,7 +90,7 @@ run-jupyter:
9090
## run-web-app: runs the FastAPI api with hot reloading
9191
.PHONY: run-web-app
9292
run-web-app:
93-
PYTHONPATH=$(realpath .) uvicorn ${PACKAGE_NAME}.api.app:app --reload
93+
PYTHONPATH=$(realpath .) uvicorn ${PACKAGE_NAME}.api.app:app --log-config logger_config.yaml --reload
9494

9595

9696
#################

logger_config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 1
2+
disable_existing_loggers: False
3+
formatters:
4+
default_format:
5+
"()": uvicorn.logging.DefaultFormatter
6+
format: '%(asctime)s %(name)s %(levelname)s %(message)s'
7+
access:
8+
"()": uvicorn.logging.AccessFormatter
9+
format: '%(asctime)s %(client_addr)s %(request_line)s - %(status_code)s'
10+
handlers:
11+
access_handler:
12+
formatter: access
13+
class: logging.StreamHandler
14+
stream: ext://sys.stderr
15+
standard_handler:
16+
formatter: default_format
17+
class: logging.StreamHandler
18+
stream: ext://sys.stderr
19+
loggers:
20+
uvicorn.error:
21+
level: INFO
22+
handlers:
23+
- standard_handler
24+
propagate: no
25+
# disable logging for uvicorn.error by not having a handler
26+
uvicorn.access:
27+
level: INFO
28+
handlers:
29+
- access_handler
30+
propagate: no
31+
# disable logging for uvicorn.access by not having a handler
32+
unstructured:
33+
level: INFO
34+
handlers:
35+
- standard_handler
36+
propagate: no
37+

0 commit comments

Comments
 (0)