Skip to content

Commit 4fccbe5

Browse files
KochankovIDrestyled-io[bot]restyled-commits
authored
update logger (#17)
* update logger * Restyle update logger (#18) * Restyled by reorder-python-imports * Restyled by shfmt * Restyled by yapf * Restyled by black * Restyled by isort Co-authored-by: Restyled.io <[email protected]> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <[email protected]>
1 parent 16a7cf8 commit 4fccbe5

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

core/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from core.loger import LOGGING
2+
3+
logconfig_dict = LOGGING
4+
access_log_format = "%(h)s"

core/loger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def filter(self, record):
105105
},
106106
},
107107
"loggers": {
108+
"gunicorn": {"propagate": 1}
108109
# "cv.request": {"level": "DEBUG", "handlers": ["console"]},
109110
# "werkzeug": {"level": "DEBUG", "handlers": ["console"]},
110111
},

main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
from logging.config import dictConfig
34

45
from apispec import APISpec
@@ -98,3 +99,7 @@ def check_for_maintenance():
9899

99100
if __name__ == "__main__":
100101
app.run(debug=DEBUG, port=8000)
102+
else:
103+
gunicorn_logger = logging.getLogger("gunicorn.error")
104+
app.logger.handlers = gunicorn_logger.handlers
105+
app.logger.setLevel(gunicorn_logger.level)

scripts/flask-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# Start server
44
echo "Starting server"
5-
gunicorn --access-logfile - --log-file - --log-level DEBUG --bind 0.0.0.0:8000 main:app
5+
gunicorn -c core/config.py --bind 0.0.0.0:8000 main:app

0 commit comments

Comments
 (0)